使用debezium从Postgres进行流更改
已完成设置:
问题:当我启动观察程序时,它正在读取较早发生的所有更改,但是当任何插入完成时,kafka会向debezium抛出一个异常,说“ An exception occurred in the change event producer. This connector will be stopped.
”,并且在观察程序中没有显示。
由于我对这些概念还很陌生,无法弄清我在环境设置中缺少的内容,这是我在堆栈溢出中遇到的第一个问题,请忽略我的错误。
主要问题是我的本地数据库工作正常。
有人可以帮忙吗?
预先感谢
019-05-02 14:09:47,242 WARN Postgres|kafkaserver|records-stream-producer Closing replication stream due to db connection IO exception... [io.debezium.connector.postgresql.RecordsStreamProducer]
2019-05-02 14:09:47,365 INFO || WorkerSourceTask{id=kafka-public-connector-0} Committing offsets [org.apache.kafka.connect.runtime.WorkerSourceTask]
2019-05-02 14:09:47,366 INFO || WorkerSourceTask{id=kafka-public-connector-0} flushing 0 outstanding messages for offset commit [org.apache.kafka.connect.runtime.WorkerSourceTask]
2019-05-02 14:09:47,375 ERROR || WorkerSourceTask{id=kafka-public-connector-0} Task threw an uncaught and unrecoverable exception [org.apache.kafka.connect.runtime.WorkerTask]
org.apache.kafka.connect.errors.ConnectException: An exception ocurred in the change event producer. This connector will be stopped.
at io.debezium.connector.base.ChangeEventQueue.throwProducerFailureIfPresent(ChangeEventQueue.java:170)
at io.debezium.connector.base.ChangeEventQueue.poll(ChangeEventQueue.java:151)
at io.debezium.connector.postgresql.PostgresConnectorTask.poll(PostgresConnectorTask.java:161)
at org.apache.kafka.connect.runtime.WorkerSourceTask.poll(WorkerSourceTask.java:245)
at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:221)
at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:175)
at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:219)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.postgresql.util.PSQLException: Database connection failed when reading from copy
at org.postgresql.core.v3.QueryExecutorImpl.readFromCopy(QueryExecutorImpl.java:1037)
at org.postgresql.core.v3.CopyDualImpl.readFromCopy(CopyDualImpl.java:41)
at org.postgresql.core.v3.replication.V3PGReplicationStream.receiveNextData(V3PGReplicationStream.java:155)
at org.postgresql.core.v3.replication.V3PGReplicationStream.readInternal(V3PGReplicationStream.java:124)
at org.postgresql.core.v3.replication.V3PGReplicationStream.read(V3PGReplicationStream.java:70)
at io.debezium.connector.postgresql.connection.PostgresReplicationConnection$1.read(PostgresReplicationConnection.java:251)
at io.debezium.connector.postgresql.RecordsStreamProducer.streamChanges(RecordsStreamProducer.java:134)
at io.debezium.connector.postgresql.RecordsStreamProducer.lambda$start$0(RecordsStreamProducer.java:120)
... 5 more
Caused by: java.io.EOFException
at org.postgresql.core.PGStream.receiveChar(PGStream.java:308)
at org.postgresql.core.v3.QueryExecutorImpl.processCopyResults(QueryExecutorImpl.java:1079)
at org.postgresql.core.v3.QueryExecutorImpl.readFromCopy(QueryExecutorImpl.java:1035)
... 12 more
2019-05-02 14:09:47,387 ERROR || WorkerSourceTask{id=kafka-public-connector-0} Task is being killed and will not recover until manually restarted [org.apache.kafka.connect.runtime.WorkerTask]
答案 0 :(得分:0)
谢谢大家。以上问题已解决。远程数据库中安装的实际问题。解决了正确安装的问题后,只有很少的其他依赖项无法正确安装,例如postgis,protobuf-c,decoderbufs。
答案 1 :(得分:0)
对我来说,我检查了rds数据库实例的Replication_Slot大小,它是非活动的。我使用下面的查询来获取replication_slot的状态
select slot_name, pg_size_pretty(pg_xlog_location_diff(pg_current_xlog_location(),restart_lsn)) as replicationSlotLag, active from pg_replication_slots ;
如果actice列的值为'f',则表明它处于非活动状态,并且连接器无法连接到数据库。由于复制插槽已处于非活动状态,因此我使用以下语句将其删除
select pg_drop_replication_slot('your_slot_name');
此后,重新启动连接器即可解决此错误。