Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [Connector-V2][Postgres-CDC] Read SnapshotSplit error due to java.lang.NullPointerException #8539

Open
3 tasks done
litiliu opened this issue Jan 16, 2025 · 1 comment · May be fixed by #8547
Open
3 tasks done
Labels

Comments

@litiliu
Copy link
Contributor

litiliu commented Jan 16, 2025

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

The NPE was thrown when running within the local IDE, the PG version is 17. My maven dependencies of seatunnel-examples/seatunnel-flink-connector-v2-example/pom.xml

        <dependency>
            <groupId>org.apache.seatunnel</groupId>
            <artifactId>connector-cdc-postgres</artifactId>
            <version>${revision}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.7.5</version>
        </dependency>

SeaTunnel Version

2.3.9

SeaTunnel Config

{
  "env": {
    "job.mode": "STREAMING",
    "parallelism": 1
  },
  "source": [
    {
      "plugin_name": "Postgres-CDC",
      "base-url": "jdbc:postgresql://localhost:4000/postgres?loggerLevel=OFF",
      "username": "un",
      "password": "pd",
      "table-names": ["postgres.up.test_cdc"],
      "schema-names": ["up"],
      "database-names": ["postgres"],
      "exactly_once": false
    }
  ],
  "sink": [
    {
      "plugin_name": "Console"
    }
  ]
}

Running Command

src/main/java/org/apache/seatunnel/example/flink/v2/SeaTunnelApiExample.java

Error Exception

Caused by: org.apache.seatunnel.common.utils.SeaTunnelException: Read split SnapshotSplit(tableId=postgres.udp.test_cdc, splitKeyType=null, splitStart=null, splitEnd=null, lowWatermark=null, highWatermark=null) error due to java.lang.NullPointerException.
	at org.apache.seatunnel.connectors.cdc.base.source.reader.external.IncrementalSourceScanFetcher.checkReadException(IncrementalSourceScanFetcher.java:216) ~[classes/:?]
	at org.apache.seatunnel.connectors.cdc.base.source.reader.external.IncrementalSourceScanFetcher.pollSplitRecords(IncrementalSourceScanFetcher.java:117) ~[classes/:?]
	at org.apache.seatunnel.connectors.cdc.base.source.reader.IncrementalSourceSplitReader.fetch(IncrementalSourceSplitReader.java:75) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.common.source.reader.fetcher.FetchTask.run(FetchTask.java:54) ~[connector-file-s3-2.3.9-SNAPSHOT.jar:2.3.9-SNAPSHOT]
	at org.apache.seatunnel.connectors.seatunnel.common.source.reader.fetcher.SplitFetcher.runOnce(SplitFetcher.java:162) ~[connector-file-s3-2.3.9-SNAPSHOT.jar:2.3.9-SNAPSHOT]
	... 7 more
Caused by: io.debezium.DebeziumException: java.lang.NullPointerException
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask.execute(PostgresSnapshotSplitReadTask.java:112) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotFetchTask.execute(PostgresSnapshotFetchTask.java:65) ~[classes/:?]
	at org.apache.seatunnel.connectors.cdc.base.source.reader.external.IncrementalSourceScanFetcher.lambda$submitTask$0(IncrementalSourceScanFetcher.java:96) ~[classes/:?]
	... 6 more
Caused by: java.lang.NullPointerException
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask.createDataEventsForTable(PostgresSnapshotSplitReadTask.java:183) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask.createDataEvents(PostgresSnapshotSplitReadTask.java:170) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask.doExecute(PostgresSnapshotSplitReadTask.java:136) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask.execute(PostgresSnapshotSplitReadTask.java:107) ~[classes/:?]
	at org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotFetchTask.execute(PostgresSnapshotFetchTask.java:65) ~[classes/:?]
	at org.apache.seatunnel.connectors.cdc.base.source.reader.external.IncrementalSourceScanFetcher.lambda$submitTask$0(IncrementalSourceScanFetcher.java:96) ~[classes/:?]

Zeta or Flink or Spark Version

Flink 1.18.1

Java or Scala Version

java 11

Screenshots

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@litiliu litiliu added the bug label Jan 16, 2025
@litiliu
Copy link
Contributor Author

litiliu commented Jan 17, 2025

In the org.apache.seatunnel.connectors.seatunnel.cdc.postgres.source.reader.snapshot.PostgresSnapshotSplitReadTask#createDataEvents

TableId newTableId = new TableId(null, tableId.schema(), tableId.table());
createDataEventsForTable(
        snapshotContext, snapshotReceiver, databaseSchema.tableFor(newTableId));

newTableId has a null catalogName field, thus lead to databaseSchema.tableFor(newTableId) return null value.

@litiliu litiliu changed the title [Bug] [Connector-V2][Postgres-CDC] Read split SnapshotSplit error due to java.lang.NullPointerException [Bug] [Connector-V2][Postgres-CDC] Read SnapshotSplit error due to java.lang.NullPointerException Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant