Kafka cross-partition ordering causes dropped Glue entries on concurrent HMS operations
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java, kafka
- Domain
- backend, databases, distributed-systems
Research direction
Start with KafkaMessageSender and its partitioning comment to trace how DROP and RENAME events can arrive out of order across consumers. Then inspect ApiaryGlueSync.onAlterTable and doRenameOperation, using the described DROP-then-RENAME reproduction. Done means the ordering issue has an agreed safe handling strategy and an Iceberg rename removes the old Glue entry without leaving either name incorrect.
Written by the indexing model from the issue text.
Description
Two bugs cause broken Glue state after Iceberg table rename
This issue covers two independent bugs that both manifest when an Iceberg table is renamed to a
name freed by a prior drop. Each bug produces a different broken Glue entry. They require
separate fixes.
Before
| Table | HMS | Glue |
|---|---|---|
db.table |
exists (Hive) | exists |
db.table_iceberg |
exists (Iceberg) | exists |
Steps to reproduce
Perform these two HMS operations in order, within the same second:
DROP TABLE db.table(freeing the name)RENAME db.table_iceberg → db.table
Expected after
| Table | HMS | Glue |
|---|---|---|
db.table |
exists (Iceberg, renamed from table_iceberg) |
exists |
db.table_iceberg |
does not exist | does not exist |
Actual after
| Table | HMS | Glue |
|---|---|---|
db.table |
exists (Iceberg) | does not exist |
db.table_iceberg |
does not exist | still exists (orphaned) |
Bug 1 — Kafka cross-partition ordering deletes the renamed table
What happens
Each HMS operation produces a Kafka message keyed on database.tableName (ALTER events use the
old table name per KafkaMetaStoreEventListener.withPayload):
| HMS operation | Partition key | Glue operation |
|---|---|---|
DROP table |
db.table |
DeleteTable(table) |
RENAME table_iceberg → table |
db.table_iceberg |
UpdateTable(table) |
Two different partition keys → two different Kafka partitions → two different consumer pods,
with no ordering guarantee between them.
HMS (sequential) Kafka partition Consumer pod
────────────────────────────────────────────────────────────────────
T+0 DROP table → partition A → Pod 1
T+1 RENAME table_iceberg→table → partition B → Pod 2
Pod 2 (partition B) Pod 1 (partition A)
─────────────────── ───────────────────
T+n UpdateTable(table) ✓
T+n+1 DeleteTable(table) ✗ ← undoes Pod 2
Pod 1 and Pod 2 each see a valid, in-order stream on their own partition. GlueSync records both
calls as result:success. The DROP was issued before the RENAME in HMS but arrived at Glue one
second after it, deleting db.table.
Root cause
KafkaMessageSender hashes qualifiedTableName to select a partition:
int partition = Math.abs(kafkaMessage.getQualifiedTableName().hashCode() % numberOfPartitions);
The class-level comment acknowledges this: "Note that in order to preserve the order of the
events the topic must have only single partition." Cross-table operations that depend on ordering
are not safe when the topic has more than one partition.
Possible mitigations
None of these are good options. They all involve significant trade-offs with no clean solution:
| Option | Trade-off |
|---|---|
| Single-partition topic | Fully serialized — guaranteed ordering, no parallelism |
Partition by database instead of database.table |
All tables in a DB serialize; fixes cross-table ordering within a DB |
| Idempotent consumer with version checks | Complex; requires GlueSync to compare event timestamps before destructive ops |
Bug 2 — Iceberg rename path never deletes the old Glue entry
What happens
ApiaryGlueSync.onAlterTable routes Iceberg renames through updateOrCreateTable(newTable),
which calls UpdateTable (or CreateTable on EntityNotFoundException). It never deletes the
old Glue entry, so db.table_iceberg is left as an orphan regardless of whether Bug 1 occurs.
Root cause
// Only Hive renames go through doRenameOperation, which creates new + deletes old.
// Iceberg renames skip it and fall through to updateOrCreateTable — no delete of old name.
if (isTableRename(oldTable, newTable) && !isIcebergPredicate.test(oldTable.getParameters())) {
doRenameOperation(oldTable, newTable);
return;
}
updateOrCreateTable(newTable);
Fix
Remove the !isIcebergPredicate guard so all renames go through doRenameOperation:
if (isTableRename(oldTable, newTable)) {
doRenameOperation(oldTable, newTable);
return;
}
updateOrCreateTable(newTable);
- Dominant language
- Java
- Stars
- 13
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ExpediaGroup/apiary-extensions
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in ExpediaGroup/apiary-extensions
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
avaje/avaje-metrics#142 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RamazanKara/nightjar#299 ·
-
Support emergency=access_point (POI type and rendering)Possibly taken @julenepj claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
osmandapp/OsmAnd#27424 · 1 comment ·
Maintainers usually reply within 1 day
-
Link not working in the feedback concerning String.format() in exercise 'Tim from Marketing'Possibly taken @LaibaMunir016 claimed this 1 day ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 88/100
exercism/java-analyzer#379 · 1 comment ·