Skip to content

Fix table schema map registration for table-model TsFiles - #19100

Merged
jt2594838 merged 7 commits into
apache:masterfrom
luoluoyuyu:fix/table-schema-registration
Nov 5, 2026
Merged

jt2594838 merged 7 commits into
apache:masterfrom
luoluoyuyu:fix/table-schema-registration

Conversation

@luoluoyuyu

@luoluoyuyu luoluoyuyu commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Table-model TsFiles are identified by a non-empty TableSchema map. A table could have chunks in a file while its schema map entry was missing or removed, causing the file to be treated as a tree-model file and loaded with zero rows.

This change only fixes map membership and preserves the existing TableSchema content:

  • Register a missing TableSchema entry for every table that already has chunks during normal flush and unsealed-file recovery.
  • Keep an existing schema entry untouched; do not synthesize a TIME column when it was not present before.
  • Retain the schema entry for tables that wrote chunk groups during compaction, even when the schema has no FIELD/TIME column.
  • Preserve a TIME column during compaction only when it already exists in the source TableSchema.

LoadTsFileAnalyzer is intentionally untouched.

Tests

  • New unit tests for missing-schema registration, including a time-only table entry.
  • Compaction schema/writer unit tests.
  • Two-cluster integration test: producer writes and compacts a table-model TsFile, then a separate cluster loads it and verifies the row count.
  • Full English and Chinese test compilation passed.
  • spotless:check and git diff --check passed.

@Caideyipi Caideyipi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed commit f868dc1. I found no actionable issues in the diff. The changes preserve table-schema entries at normal file close, WAL recovery, and compaction boundaries. I did not run the newly added tests locally; the related unit-test and dual-table integration CI jobs are still pending.

Keep the TableSchema map entry for every table that has chunk data in a TsFile, even when the schema has no FIELD or TIME column. Restore missing entries during flush and recovery, and retain them during compaction so table-model files do not degrade into tree-model files.

Add unit tests and a two-cluster integration test covering compaction and LOAD.
@luoluoyuyu
luoluoyuyu force-pushed the fix/table-schema-registration branch from f868dc1 to 2c6e96f Compare November 3, 2026 04:33
…LOAD

Write a single isTableModel file property when a table-model TsFile is closed by flush, compaction, recovery and the pipe sink, so a file whose TableSchema map is empty is no longer mistaken for a tree-model file. The property is constant time and independent of the number of tables.

LOAD now completes a schema entry that has no column other than time, and an entry that is missing, from the table in IoTDB, and only fails with a dedicated message when the table exists neither in the file nor in IoTDB. The storage path keeps its previous behavior: it neither synthesizes entries for dropped tables nor scans chunks during recovery.

Add unit tests for the file property, the model detection and the schema completion, and an integration test covering time-only entries, missing entries and table creation.
CompactionTableSchema.merge behaves exactly as before: it merges id columns and never keeps the TIME column. Keeping the table-name entry of a table that wrote data into the target file is enough for a compacted file to stay identifiable, so the merge decision does not need to change.

Restore the corresponding unit tests.
Compaction drops a TableSchema again when it has no FIELD or TIME column, as it did before this change. The target file stays identifiable through the isTableModel file property, so the writer only records that property, read before the unused entries are removed.
The compaction writer learns the model from the database it compacts, so the isTableModel property is written whenever the target file belongs to a table-model database, even when its TableSchema map keeps no entry.

Assert the property in the compaction and LOAD integration test.
…ealed

The marker is one entry of the in-memory file property map, serialized by endFile(). Spell that out at the helper and at the flush and pipe call sites so the marker is never moved to a per-record, per-tablet or per-chunk-group position.
UnsealedTsFileRecoverPerformer derived the data model from the database
name via PathUtils.isTableModelDatabase, and the table-schema registration
helper repeated the same name-based check. That duplicates knowledge the
owning DataRegion already holds through its isTableModel field and
misclassifies a table-model region whose database name happens to start
with "root.", which leaves the recovered TsFile with the chunks of a table
but no TableSchema entry for them.

Pass DataRegion.isTableModel into the recover performer, gate the schema
registration on it, and keep databaseName only as the DataNodeTableCache
lookup key. Update the recovery tests to pass the model explicitly and
turn the registration-helper test into a check that the database name is
never inspected to guess the model.
@jt2594838
jt2594838 merged commit 24e1203 into apache:master Nov 5, 2026
39 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.

3 participants