Skip to content

HDDS-15288. Use SequenceIdType in StateManagerImpl.#10313

Open
navinko wants to merge 1 commit into
apache:masterfrom
navinko:HDDS-15288
Open

HDDS-15288. Use SequenceIdType in StateManagerImpl.#10313
navinko wants to merge 1 commit into
apache:masterfrom
navinko:HDDS-15288

Conversation

@navinko
Copy link
Copy Markdown
Contributor

@navinko navinko commented May 19, 2026

What changes were proposed in this pull request?

Used SequenceIdType for sequenceIdToLastIdMap in StateManagerImpl

Please describe your PR in detail:

Refactored sequenceIdToLastIdMap in StateManagerImpl from <String, Long> to <SequenceIdType, Long>.
Updated allocateBatch(), getLastId(), and initialize() to safely convert DB key of string type to SequenceIdType Enums using SequenceIdType.valueOf().
Also as per the Jira, the @replicate method signatures were NOT changed to maintain RPC compatibility.

Regarding the change related to other in-memory data structure -sequenceIdTable, will create a separate PR with SequenceIdType codec by moving away from default StringCodec to support serialization and adapt SequenceIdType
for Table<String, Long> --> Table<SequenceIdType, Long>

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15288

How was this patch tested?

Added new test cases under TestSequenceIDGenerator and validated changes.
Ran locally, docker-compose and validated the flow for reinitialise with scm failover

ozonesecure-ha % docker compose logs -f scm1.org scm2.org 2>&1 | grep -iE "SequenceIdGenerator|allocateBatch"
scm2.org-1 | 2026-05-19 11:07:13,743 [main] INFO ha.SequenceIdGenerator: upgrade localId to 117883640217600000
scm2.org-1 | 2026-05-19 11:07:13,744 [main] INFO ha.SequenceIdGenerator: upgrade delTxnId to 0
scm2.org-1 | 2026-05-19 11:07:13,747 [main] INFO ha.SequenceIdGenerator: upgrade containerId to 0
scm2.org-1 | 2026-05-19 11:07:13,748 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 2
scm2.org-1 | 2026-05-19 11:07:13,748 [main] INFO ha.SequenceIdGenerator: Init the HA SequenceIdGenerator.
scm2.org-1 | 2026-05-19 11:07:14,412 [a0c35110-bb90-45b4-862f-e7d338f1a711@group-DA1743C8D70B-StateMachineUpdater] INFO ha.SequenceIdGenerator: reinitialize SequenceIdGenerator.
scm2.org-1 | 2026-05-19 11:14:28,423 [a0c35110-bb90-45b4-862f-e7d338f1a711@group-DA1743C8D70B-StateMachineUpdater] WARN ha.SequenceIdGenerator: Failed to allocate a batch for localId, expected lastId is 0, actual lastId is 117883640217600000.
scm1.org-1 | 2026-05-19 11:07:06,181 [main] INFO ha.SequenceIdGenerator: upgrade localId to 117883640217600000
scm1.org-1 | 2026-05-19 11:07:06,181 [main] INFO ha.SequenceIdGenerator: upgrade delTxnId to 0
scm1.org-1 | 2026-05-19 11:07:06,183 [main] INFO ha.SequenceIdGenerator: upgrade containerId to 0
scm1.org-1 | 2026-05-19 11:07:06,183 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 2
scm1.org-1 | 2026-05-19 11:07:06,184 [main] INFO ha.SequenceIdGenerator: Init the HA SequenceIdGenerator.
scm1.org-1 | 2026-05-19 11:07:06,296 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 2
scm1.org-1 | 2026-05-19 11:07:12,154 [9c364a4e-6060-4490-a237-6a9e96102d15@group-DA1743C8D70B-StateMachineUpdater] WARN ha.SequenceIdGenerator: Failed to allocate a batch for CertificateId, expected lastId is 0, actual lastId is 2.
scm1.org-1 | 2026-05-19 11:07:12,157 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 2 to 3.
scm1.org-1 | 2026-05-19 11:07:15,999 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 3 to 4.
scm1.org-1 | 2026-05-19 11:07:16,134 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 4 to 5.
scm1.org-1 | 2026-05-19 11:07:21,456 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 5 to 6.
scm1.org-1 | 2026-05-19 11:07:21,541 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 6 to 7.
scm1.org-1 | 2026-05-19 11:07:21,594 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 7 to 8.
scm1.org-1 | 2026-05-19 11:07:21,632 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 8 to 9.
scm1.org-1 | 2026-05-19 11:07:21,666 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 9 to 10.
scm1.org-1 | 2026-05-19 11:07:21,696 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CertificateId, change lastId from 10 to 11.
scm1.org-1 | 2026-05-19 11:14:28,398 [IPC Server handler 20 on default port 9863] INFO ha.SequenceIdGenerator: Allocate a batch for containerId, change lastId from 0 to 1000.
scm1.org-1 | 2026-05-19 11:14:28,411 [9c364a4e-6060-4490-a237-6a9e96102d15@group-DA1743C8D70B-StateMachineUpdater] WARN ha.SequenceIdGenerator: Failed to allocate a batch for localId, expected lastId is 0, actual lastId is 117883640217600000.
scm1.org-1 | 2026-05-19 11:14:28,416 [IPC Server handler 20 on default port 9863] INFO ha.SequenceIdGenerator: Allocate a batch for localId, change lastId from 117883640217600000 to 117883640217601000.
scm1.org-1 | 2026-05-19 11:19:06,367 [main] INFO ha.SequenceIdGenerator: Init the HA SequenceIdGenerator.
scm1.org-1 | 2026-05-19 11:19:06,486 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 11

Successful CI build:
https://github.com/navinko/ozone/actions/runs/26101162654

@navinko
Copy link
Copy Markdown
Contributor Author

navinko commented May 19, 2026

Hi @szetszwo , added the changes. Once you get some time please review it .
Regards

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