Skip to content

Cassandra fails to start with a template NullPointerException #1996

@bohdan-natsevych

Description

@bohdan-natsevych

Bug report

What Debezium connector do you use and what version?

Debezium Server (quay.io/debezium/server:3.6.0.Alpha2) with the Cassandra 4 source connector (io.debezium.connector.cassandra.Cassandra4Connector, EXTRA_CONNECTOR: cassandra-4).


What is the connector configuration?

connector.class                              = io.debezium.connector.cassandra.Cassandra4Connector
topic.prefix                                 = cassandra
cassandra.node.id                            = docker-05-cdc
cassandra.hosts                              = cassandra
cassandra.port                               = 9042
cassandra.config                             = /debezium/config/cassandra.yaml
cassandra.driver.config.file                 = /debezium/config/driver.conf
snapshot.mode                                = NEVER
snapshot.consistency                         = QUORUM
commit.log.relocation.dir                    = /debezium/data/cdc_relocation
commit.log.real.time.processing.enabled      = true
commit.log.marked.complete.poll.interval.ms  = 100
cdc.dir.poll.interval.ms                     = 100
poll.interval.ms                             = 100
offset.storage                               = org.apache.kafka.connect.storage.FileOffsetBackingStore
offset.storage.file.filename                 = /debezium/data/offsets.dat
http.port                                    = 8040

Sink configuration:

DEBEZIUM_SINK_TYPE                  = http
DEBEZIUM_SINK_HTTP_URL              = ...
DEBEZIUM_FORMAT_KEY                 = json
DEBEZIUM_FORMAT_VALUE               = json
DEBEZIUM_FORMAT_KEY_SCHEMAS_ENABLE  = false
DEBEZIUM_FORMAT_VALUE_SCHEMAS_ENABLE = false

cassandra.yaml is a copy of the Cassandra 4.1.4 node config with GossipingPropertyFileSnitch replaced by SimpleSnitch.


What is the captured database version and mode of deployment?

On-premise Cassandra 4.1.4 with CDC enabled (cdc_enabled: true).


What behavior do you expect?

The Cassandra 4 source task starts, attaches to the node, and streams CDC commit-log events to the HTTP sink.


What behavior do you see?

Debezium Server boots, loads the Cassandra 4 connector, validates the configuration, creates the source task, and then the task fails to start with a NullPointerException. The engine transitions STARTING_TASKS -> STOPPING -> STOPPED, the process reports the connector completed with success = 'false', and the container exits with code 0.

The failure occurs in AbstractConnectorTask.preStart because this.template is null:

io.debezium.embedded.async.AsyncEmbeddedEngine - Task #1 (out of 1 tasks) failed to start. Failed with
java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke
  "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.getTaskContext()" because "this.template" is null
    at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
    at io.debezium.embedded.async.AsyncEmbeddedEngine.startSourceTasks(AsyncEmbeddedEngine.java:473)
    at io.debezium.embedded.async.AsyncEmbeddedEngine.run(AsyncEmbeddedEngine.java:220)
    at io.debezium.server.DebeziumServer.lambda$start$0(DebeziumServer.java:166)
    ...
Caused by: java.lang.NullPointerException: Cannot invoke
  "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.getTaskContext()" because "this.template" is null
    at io.debezium.connector.cassandra.AbstractConnectorTask.preStart(AbstractConnectorTask.java:52)
    at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:253)
    at io.debezium.embedded.async.AsyncEmbeddedEngine.lambda$startSourceTasks$2(AsyncEmbeddedEngine.java:452)
    ...

During the subsequent stop, a second NPE is raised for the same null template field:

io.debezium.connector.cassandra.exceptions.CassandraConnectorTaskException:
  java.lang.NullPointerException: Cannot invoke
  "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.stopAll()" because "this.template" is null
    at io.debezium.connector.cassandra.AbstractConnectorTask.doStop(AbstractConnectorTask.java:106)
    at io.debezium.connector.common.BaseSourceTask.stop(BaseSourceTask.java:529)
    ...
Caused by: java.lang.NullPointerException: Cannot invoke
  "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.stopAll()" because "this.template" is null
    at io.debezium.connector.cassandra.AbstractConnectorTask.doStop(AbstractConnectorTask.java:103)

The last log lines before the source task threads run, CassandraSourceInfoStructMaker is loaded but the task never reaches connection to the Cassandra node:

io.debezium.config.CommonConnectorConfig - Loading the custom source info struct maker plugin:
  io.debezium.connector.cassandra.CassandraSourceInfoStructMaker
io.debezium.embedded.async.AsyncEmbeddedEngine - Task #1 (out of 1 tasks) failed to start.

Do you see the same behaviour using the latest released Debezium version?

Observed on 3.6.0.Alpha2 (the latest 3.6 build published on quay.io at time of report; no 3.6.0.Final exists yet). The same CassandraConnectorTaskTemplate.getTaskContext() / this.template null NPE was previously observed on 3.4.0 and 3.4.1.

3.2.0.Final does not exhibit this failure and start normally.


Do you have the connector logs, ideally from start till finish?

Yes. The connector was run with DEBUG-level logging. Relevant excerpt (full boot to exit):

debezium-server  | Connector - cassandra-4 loaded from connectors/debezium-connector-cassandra-4
debezium-server  | [io.quarkus] debezium-server-dist 3.6.0.Alpha2 on JVM (powered by Quarkus 3.27.1) started in 3.024s.
debezium-server  | io.debezium.server.http.HttpChangeConsumer - Using sink URL: http://debezium-to-opensearch-proxy:8088/cdc
debezium-server  | io.debezium.server.ChangeConsumerFactory - Consumer 'io.debezium.server.http.HttpChangeConsumer' instantiated
debezium-server  | io.debezium.server.DebeziumServer - Engine executor started
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Engine state has changed from 'CREATING' to 'INITIALIZING'
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Connector configuration is valid.
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Engine state has changed from 'INITIALIZING' to 'CREATING_TASKS'
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Creating 1 instance(s) of source task(s)
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Engine state has changed from 'CREATING_TASKS' to 'STARTING_TASKS'
debezium-server  | io.debezium.connector.common.BaseSourceTask - Setting task state to 'INITIAL', previous state was 'INITIAL'
debezium-server  | io.debezium.config.CommonConnectorConfig - Loading the custom source info struct maker plugin: io.debezium.connector.cassandra.CassandraSourceInfoStructMaker
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Task #1 (out of 1 tasks) failed to start. Failed with
debezium-server  | java.util.concurrent.ExecutionException: java.lang.NullPointerException: Cannot invoke "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.getTaskContext()" because "this.template" is null
debezium-server  |      at io.debezium.connector.cassandra.AbstractConnectorTask.preStart(AbstractConnectorTask.java:52)
debezium-server  |      at io.debezium.connector.common.BaseSourceTask.start(BaseSourceTask.java:253)
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - 1 task(s) out of 1 failed to start.
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Engine has failed with
debezium-server  | io.debezium.server.ConnectorLifecycle - Connector completed: success = 'false', message = 'java.lang.NullPointerException: Cannot invoke "io.debezium.connector.cassandra.CassandraConnectorTaskTemplate.getTaskContext()" because "this.template" is null'
debezium-server  | io.debezium.embedded.async.AsyncEmbeddedEngine - Engine state has changed from 'STOPPING' to 'STOPPED'
debezium-server  | [io.quarkus] debezium-server-dist stopped in 0.043s
debezium-server exited with code 0

How to reproduce the issue using our [tutorial](https://github.com/debezium/debezium-examples/tree/main/tutorial) deployment?

Run Debezium Server 3.6.0.Alpha2 with the Cassandra 4 connector (EXTRA_CONNECTOR: cassandra-4, connector.class=io.debezium.connector.cassandra.Cassandra4Connector) against a Cassandra 4.1.4 node with CDC enabled, on Java 21, using the configuration shown above. The source task fails on start in AbstractConnectorTask.preStart with the this.template NPE before connecting to the node.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions