You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "luoyuxia (via GitHub)" <gi...@apache.org> on 2026/10/15 09:04:21 UTC
[I] [server] Old table cleanup removes recreated table path mapping [fluss]
luoyuxia opened a new issue, #4655:
URL: https://github.com/apache/fluss/issues/4655
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing identical. #3483 also involves drop/recreate, but concerns stale lake snapshot paths rather than the Coordinator's table-path mapping.
### Fluss version
main (development). The failure symptom was observed on a downstream 0.9-ali-1.0 build; the `CoordinatorContext.removeTable` behavior described below is also present on current Apache Fluss `main`.
### Please describe the bug 🐞
`CoordinatorContext` keeps both `tablePathById` and `tableIdByPath`. When a table is dropped, its ZooKeeper table node is deleted first, while replica/assignment cleanup completes later. This allows a table with the same path to be created with a new ID before the old ID reaches `CoordinatorContext.removeTable`.
For a path `P`, old ID `X`, and new ID `Y`, the following state transition loses the new table's reverse mapping:
1. The old table has `tablePathById[X] = P` and `tableIdByPath[P] = X`.
2. Drop `X`, then recreate `P` as `Y` before the old cleanup completes. `putTablePath(Y, P)` sets `tableIdByPath[P] = Y`; `tableInfoById[Y]` is populated.
3. The delayed cleanup calls `removeTable(X)`. It removes `tablePathById[X]`, then unconditionally calls `tableIdByPath.remove(P)`, even though that entry now belongs to `Y`.
4. `getTableIdByPath(P)` returns `UNKNOWN_TABLE_ID`, while `getTableInfoById(Y)` can still return the new table.
A small `CoordinatorContext` unit test can reproduce the mapping loss without relying on timing:
```java
context.putTablePath(oldId, path);
context.putTablePath(newId, path);
context.removeTable(oldId);
assertThat(context.getTableIdByPath(path)).isEqualTo(newId); // currently fails
```
**Expected:** Completing deletion of `X` must preserve the mapping `P -> Y`.
**Actual:** The mapping is removed. A subsequent table registration change resolves `P` to `UNKNOWN_TABLE_ID`; `processTableRegistrationChange` checks only for `null`, so it obtains a null `oldTableInfo` and can throw at `oldTableInfo.getSchemaInfo()`. The lake tiering manager may still retain `Y`, because its state is keyed separately by table ID.
We observed repeated `TablePropertiesChangeEvent` failures when setting `table.datalake.enabled=false`, with `oldTableInfo` null, while tiering continued to request the affected table. The historical drop/recreate sequence for that deployment is unavailable, so this production symptom is consistent with, but does not prove, the race above.
### Solution
In `CoordinatorContext.removeTable`, remove the reverse mapping only if it still points to the table being deleted, for example `tableIdByPath.remove(tablePath, tableId)`. Add a regression test for the old-ID/new-ID sequence above. Also handle `UNKNOWN_TABLE_ID` (and a missing `TableInfo`) in `processTableRegistrationChange` with a diagnostic log instead of a `NullPointerException`; that guard alone would not preserve the mapping.
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org