Skip to content

[AMORO-4257][AMS] Fix duplicate process ID caused by multiple SnowflakeIdGenerator instances#4258

Open
felixhzhu wants to merge 1 commit into
apache:masterfrom
felixhzhu:fix-snowflake-id-collision
Open

[AMORO-4257][AMS] Fix duplicate process ID caused by multiple SnowflakeIdGenerator instances#4258
felixhzhu wants to merge 1 commit into
apache:masterfrom
felixhzhu:fix-snowflake-id-collision

Conversation

@felixhzhu

@felixhzhu felixhzhu commented Jun 22, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

Fix duplicate process ID generation caused by multiple independent SnowflakeIdGenerator
instances in the same AMS JVM.

Root Cause

Two separate static SnowflakeIdGenerator instances existed:

  • IcebergTableUtil.snowflakeIdGenerator (for optimizing process IDs)
  • TableProcessMeta.idGenerator (for maintenance process IDs)

Both used default machineId = 0 and maintained independent sequence counters.
When both entered the same 10ms time window, they generated identical IDs, causing
PRIMARY KEY conflicts in the table_process table.

Fix

Consolidate to a single global singleton SnowflakeIdGenerator.INSTANCE, ensuring
the synchronized lock and sequence counter work correctly across all callers.

How was this patch tested?

…keIdGenerator instances

Consolidate multiple independent SnowflakeIdGenerator instances into a single global singleton (SnowflakeIdGenerator.INSTANCE) to prevent ID collisions when two instances generate IDs in the same 10ms time window with the same machineId=0.

fix apache#4257
@github-actions github-actions Bot added the module:ams-server Ams server module label Jun 22, 2026
@xxubai xxubai added this to the Release 0.9.0 milestone Jun 22, 2026
@xxubai xxubai changed the title Fix duplicate process ID caused by multiple SnowflakeIdGenerator instances[AMORO-4257][AMS] Fix duplicate process ID caused by multiple Snowfla… [AMORO-4257][AMS] Fix duplicate process ID caused by multiple SnowflakeIdGenerator instances Jun 22, 2026

@xxubai xxubai left a comment

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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ams-server Ams server module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Duplicate process ID generated by multiple SnowflakeIdGenerator instances causing PRIMARY KEY conflict

2 participants