Skip to content

HDDS-15370. Change sequenceIdTable to use SequenceIdType#10381

Merged
szetszwo merged 3 commits into
apache:masterfrom
navinko:HDDS-15370
May 30, 2026
Merged

HDDS-15370. Change sequenceIdTable to use SequenceIdType#10381
szetszwo merged 3 commits into
apache:masterfrom
navinko:HDDS-15370

Conversation

@navinko
Copy link
Copy Markdown
Contributor

@navinko navinko commented May 28, 2026

What changes were proposed in this pull request?

Refactored the sequenceIdTable from Table<String, Long> to Table<SequenceIdType, Long>, adapting SequenceIdType for our in-memory data structure - sequenceIdTable. To handle this cleanly, I introduced a new SequenceIdTypeCodec implementation that serializes the enum constants to the exact same binary format as the old strings, ensuring absolute compatibility and continuity on disk.

Please describe your PR in detail:

While refactoring noticed SCMMetadataStore.java lives in the framework module and SequenceIdType.java was created inside the server-scm module. To avoid the circular dependencies, moved SequenceIdType and it's test class in framework module.

Created new codec implementation for SequenceIdType- "SequenceIdTypeCodec" and updated SCMDBDefinition by replacing with StringCodec.
Updated SCMMetadataStore and it's implementation with required changes.
Updated SequenceIdGenerator for adapting SequenceIdType under sequenceIdTable.
Added new test for SequenceIdTypeCodec ensuring serialization and desrialization works as it is.

What is the link to the Apache JIRA

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

How was this patch tested?

Unit test with new test class-TestSequenceIdTypeCodec
Ran docker-compose locally with secure cluster and validated the logs
HDDS-15370.log
CI build Successful : https://github.com/navinko/ozone/actions/runs/26605659056

@navinko navinko marked this pull request as draft May 28, 2026 22:54
@navinko navinko marked this pull request as ready for review May 29, 2026 12:41
@navinko
Copy link
Copy Markdown
Contributor Author

navinko commented May 29, 2026

Hi @szetszwo
Kindly review once you get some time.

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navinko , thanks for working on this!

Please see the comments inlined and also
https://issues.apache.org/jira/secure/attachment/13082559/10381_review.patch

/**
* Codec to serialize/deserialize {@link SequenceIdType}.
*/
public final class SequenceIdTypeCodec implements Codec<SequenceIdType> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We should cache all the results (instead of encoding to/decoding from string every time)
  • Since SequenceIdType is very small, let's move the codec to SequenceIdType.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @szetszwo for the review and sharing required patch . It make sense catch all at once in construction by using byteArray and byteBuffer and while reading from SEQUENCE_ID_TYPES map.

public void testCodecBuffersWithOzoneTestUtil() throws Exception {
for (SequenceIdType type : SequenceIdType.values()) {
// Verify codec compatibility with heap and direct byte buffers.
CodecTestUtil.runTest(enumCodec, type, null, null);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass also the serializedSize.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied the patch .Its being passed now type.getByteArray().length

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @szetszwo for the review. Tried addressing review suggestions.
Fixed checktyle issue for sequenceIdTypes
Fixed findBug issue for getByteArray
Tested locally with docker-compose by writing some data followed by scm failover and getting key info , found no error in SCM logs.
Attached log file from all 3 scm
HDDS-15370_ALL_SCM_LOGS.txt
CI Build : https://github.com/navinko/ozone/actions/runs/26662954429 (Progressing)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @szetszwo .
Please feel free to tag me for any new jira , will be happy to work .
Regards

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navinko , Please see if you are interested in continuing the work in #8576 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navinko , Please see if you are interested in continuing the work in #8576 ?

Thanks @szetszwo i will work on it .

Copy link
Copy Markdown
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@szetszwo szetszwo merged commit 5740500 into apache:master May 30, 2026
47 checks passed
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.

2 participants