fluss icon indicating copy to clipboard operation
fluss copied to clipboard

[server] Stale or wrong metadata served for missing and re-created tables

Open dstolis opened this issue 1 month ago • 0 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Fluss version

main (1.1-SNAPSHOT)

Please describe the bug 🐞

Found while working on #4706. Two server-side problems with missing and re-created tables:

1. Metadata requests for a missing table return UNKNOWN_SERVER_ERROR instead of TABLE_NOT_EXIST

MetadataManager#getTables throws TableNotExistException for a missing table, but its own catch (Exception e) wraps it in a FlussRuntimeException("Failed to get tables ..."). The metadata RPC then answers with UNKNOWN_SERVER_ERROR, so clients can't tell that the table was dropped. This is one reason why lookups on a dropped table never return (#4706).

2. Tablet servers serve stale metadata after a table is dropped and re-created under the same path

Until a tablet server receives the UpdateMetadata for the re-created table, TabletServerMetadataCache can combine metadata of the dropped and the new table:

  • getTableMetadata combines the new table's info from ZK with the dropped table's cached buckets.
  • getPartitionMetadata can return the new table id together with the dropped table's partition id for the same partition name, e.g. TableBucket{tableId=4, partitionId=2} where partition 2 belonged to the dropped table 3.

Clients then route writes to buckets or partitions that don't exist. Depending on timing, writes fail fast or hang forever in flush(). This happens on main, mostly under load (e.g. a full mvn verify -pl fluss-server,fluss-client run):

  • FlussTableITCase#testAppendAndPoll hangs, or fails with InvalidBucketRoutingException: ... requested bucket count 10, expected 1.
  • FlussLakeTableITCase#testPrimaryKeyTable and AutoPartitionedTableITCase#testPartitionedTablePrefixLookup fail with IllegalArgumentException: table path not found for tableId 3 in cluster.

Solution

  • Rethrow TableNotExistException in MetadataManager#getTables instead of wrapping it, so clients get TABLE_NOT_EXIST.
  • In TabletServerMetadataCache, serve cached table metadata only if the table id in ZK matches the cached one, and serve a cached partition only if ZK registers that partition name with the same table id and partition id. Otherwise fall back to ZK.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

dstolis avatar Oct 20 '26 08:10 dstolis