Skip to content

debezium/dbz#1488 Fix race condition in RedisOffsetBackingStore causi… - #2

Draft
mrtworo wants to merge 1 commit into
mainfrom
dbz#1488
Draft

debezium/dbz#1488 Fix race condition in RedisOffsetBackingStore causi…#2
mrtworo wants to merge 1 commit into
mainfrom
dbz#1488

Conversation

@mrtworo

@mrtworo mrtworo commented Jan 8, 2026

Copy link
Copy Markdown
Owner

…ng infinite NPE loop.

When Redis becomes temporarily unavailable, a race condition can occur:

  • Thread A catches RedisClientConnectionException and calls connect()
  • connect() calls closeClient() which sets client = null
  • Thread B concurrently tries to use client.hset() and gets NullPointerException
  • NPE is not a RedisClientConnectionException, so no reconnect is attempted
  • Thread B retries indefinitely with null client, causing infinite NPE loop

Fix:

  • Make client field volatile for cross-thread visibility
  • Add null checks in load() and save() that throw RedisClientConnectionException
    when client is null, triggering the existing reconnect logic

@mrtworo
mrtworo force-pushed the dbz#1488 branch 3 times, most recently from d199214 to b8716c0 Compare January 8, 2026 13:32
…ng infinite NPE loop

When Redis becomes temporarily unavailable, a race condition can occur:
- Thread A catches RedisClientConnectionException and calls connect()
- connect() calls closeClient() which sets client = null
- Thread B concurrently tries to use client.hset() and gets NullPointerException
- NPE is not a RedisClientConnectionException, so no reconnect is attempted
- Thread B retries indefinitely with null client, causing infinite NPE loop

Fix:
- Make client field volatile for cross-thread visibility
- Add null checks in load() and save() that throw RedisClientConnectionException
  when client is null, triggering the existing reconnect logic

Signed-off-by: Mateusz Tworek <mrtworo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant