Skip to content

[fix][meta] Fix RocksdbMetadataStore instanceId not advancing across restarts - #26218

Merged
lhotari merged 1 commit into
apache:masterfrom
SongOf:fix/metadata-rocksdb-instanceid-restart
Jul 25, 2026
Merged

[fix][meta] Fix RocksdbMetadataStore instanceId not advancing across restarts#26218
lhotari merged 1 commit into
apache:masterfrom
SongOf:fix/metadata-rocksdb-instanceid-restart

Conversation

@SongOf

@SongOf SongOf commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

RocksdbMetadataStore#loadSequentialIdGenerator is supposed to persist
the initial value of the sequential-id counter to SEQUENTIAL_ID_KEY
when no such record exists yet in RocksDB. Instead, it wrote that value
to INSTANCE_ID_KEY by mistake.

Since the constructor calls loadSequentialIdGenerator() before
loadInstanceId(), this bug clobbers INSTANCE_ID_KEY to 0 right
before loadInstanceId() reads it back — so instanceId is always
computed as 0 + 1 = 1 on startup, instead of advancing (0, 1,
2, ...) across restarts, whenever no sequential node has ever been
created in that store.

instanceId is used to tag ownership of ephemeral nodes
(metaValue.owner == instanceId), so a store stuck on the same
instanceId across restarts loses the ability to distinguish the
current process instance from a previous one for ephemeral-node
ownership checks.

Modifications

  • In RocksdbMetadataStore#loadSequentialIdGenerator, write the
    initial counter value to SEQUENTIAL_ID_KEY instead of
    INSTANCE_ID_KEY.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as
RocksdbMetadataStoreTest#testMultipleInstances and
RocksdbMetadataStoreTest#testOpenDbWithConfigFile, which exercise
store open/close/reopen cycles.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

@lhotari lhotari added this to the 5.0.0-M2 milestone Jul 23, 2026
@lhotari
lhotari merged commit a4b7aaa into apache:master Jul 25, 2026
82 of 84 checks passed
lhotari pushed a commit that referenced this pull request Jul 25, 2026
…restarts (#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
lhotari pushed a commit that referenced this pull request Jul 25, 2026
…restarts (#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
sandeep-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 31, 2026
…restarts (apache#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
sandeep-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 31, 2026
…restarts (apache#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
sandeep-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 31, 2026
…restarts (apache#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Aug 28, 2026
…restarts (apache#26218)

Co-authored-by: maxlisongsong <maxlisongsong@didiglobal.com>
(cherry picked from commit a4b7aaa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants