chore(core): fix view table id is 0 after table registry reload without tables.d file#6612
chore(core): fix view table id is 0 after table registry reload without tables.d file#6612bluestreak01 merged 4 commits intomasterfrom
Conversation
WalkthroughThis PR adds view definition detection in table registry when metadata files are absent, introduces a utility method to extract table IDs from directory names, updates relevant tests to use derived directory naming, and extends test coverage to validate view tokens, dependencies, and endpoint responses across restart scenarios. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
core/src/main/java/io/questdb/cairo/TableNameRegistryStore.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/questdb/cairo/TableNameRegistryStore.java
Outdated
Show resolved
Hide resolved
[PR Coverage check]😍 pass : 9 / 12 (75.00%) file detail
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @core/src/main/java/io/questdb/cairo/TableNameRegistryStore.java:
- Around line 313-325: In readTableId(), the call to
getTableIdFromTableDir(dirName) can throw NumericException for malformed view
dir names; wrap that call in a try-catch that catches
io.questdb.std.NumericException, log a concise warning including dirName and the
exception via the existing logger and return 0 (treat as non-table) instead of
letting the runtime exception propagate; keep behavior unchanged for valid IDs
and preserve the surrounding logic that checks
ViewDefinition.VIEW_DEFINITION_FILE_NAME.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
core/src/main/java/io/questdb/cairo/TableNameRegistryStore.javacore/src/main/java/io/questdb/cairo/TableUtils.javacore/src/test/java/io/questdb/test/cairo/TableNameRegistryTest.javacore/src/test/java/io/questdb/test/cairo/view/ViewBootstrapTest.java
🧰 Additional context used
🧬 Code graph analysis (2)
core/src/main/java/io/questdb/cairo/TableUtils.java (3)
core/src/main/java/io/questdb/std/NumericException.java (1)
NumericException(34-132)core/src/main/java/io/questdb/std/Chars.java (1)
Chars(43-1646)core/src/main/java/io/questdb/std/Numbers.java (1)
Numbers(44-3523)
core/src/test/java/io/questdb/test/cairo/view/ViewBootstrapTest.java (2)
core/src/main/java/io/questdb/std/str/Path.java (1)
Path(51-533)core/src/main/java/io/questdb/cutlass/http/client/HttpClientFactory.java (1)
HttpClientFactory(35-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (36)
- GitHub Check: New pull request (Trigger Enterprise CI Trigger Enterprise Pipeline)
- GitHub Check: New pull request (Coverage Report Coverage Report)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-other)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-pgwire)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-cairo-sub)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-cairo-root)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-fuzz2)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-fuzz1)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-griffin-sub)
- GitHub Check: New pull request (SelfHosted Running tests with cover on linux-griffin-root)
- GitHub Check: New pull request (Hosted Running tests on windows-other-2)
- GitHub Check: New pull request (Hosted Running tests on windows-other-1)
- GitHub Check: New pull request (Hosted Running tests on windows-pgwire)
- GitHub Check: New pull request (Hosted Running tests on windows-cairo-2)
- GitHub Check: New pull request (Hosted Running tests on windows-cairo-1)
- GitHub Check: New pull request (Hosted Running tests on windows-fuzz2)
- GitHub Check: New pull request (Hosted Running tests on windows-fuzz1)
- GitHub Check: New pull request (Hosted Running tests on windows-griffin-sub)
- GitHub Check: New pull request (Hosted Running tests on windows-griffin-base)
- GitHub Check: New pull request (Hosted Running tests on mac-other)
- GitHub Check: New pull request (Hosted Running tests on mac-pgwire)
- GitHub Check: New pull request (Hosted Running tests on mac-cairo-fuzz)
- GitHub Check: New pull request (Hosted Running tests on mac-cairo)
- GitHub Check: New pull request (SelfHosted Other tests on linux-x64-zfs)
- GitHub Check: New pull request (Rust Test and Lint on linux-jdk17)
- GitHub Check: New pull request (SelfHosted Other tests on linux-x86-graal)
- GitHub Check: New pull request (Hosted Running tests on mac-griffin)
- GitHub Check: New pull request (SelfHosted Cairo tests on linux-arm64)
- GitHub Check: New pull request (Trigger Enterprise CI Trigger Enterprise Pipeline)
- GitHub Check: New pull request (SelfHosted Other tests on linux-arm64)
- GitHub Check: New pull request (SelfHosted Cairo tests on linux-x64-zfs)
- GitHub Check: New pull request (SelfHosted Cairo tests on linux-x86-graal)
- GitHub Check: New pull request (SelfHosted Griffin tests on linux-x86-graal)
- GitHub Check: New pull request (SelfHosted Griffin tests on linux-arm64)
- GitHub Check: New pull request (SelfHosted Griffin tests on linux-x64-zfs)
- GitHub Check: New pull request (Check Changes Check changes)
🔇 Additional comments (9)
core/src/main/java/io/questdb/cairo/TableUtils.java (2)
65-65: LGTM: Import supports new parsing functionality.The NumericException import is correctly added to support the new
getTableIdFromTableDirmethod.
874-882: LGTM: Table ID parsing logic is sound.The method correctly extracts the table ID from directory names with the
~suffix. The error handling is appropriate, throwingNumericExceptionwhen the suffix is absent or the numeric portion is malformed.core/src/test/java/io/questdb/test/cairo/TableNameRegistryTest.java (2)
394-395: LGTM: Directory naming aligns with WAL table structure.The test correctly constructs directory names with the
~<id>suffix pattern, matching the directory structure used for WAL tables and views.
409-409: LGTM: Correctly uses directory name for file operations.Using
tableToken.getDirName()ensures the path matches the actual directory structure, which is essential for proper cleanup.core/src/main/java/io/questdb/cairo/TableNameRegistryStore.java (1)
27-27: LGTM: Import supports view detection logic.The ViewDefinition import is correctly added to support checking for view definition files in the updated
readTableIdmethod.core/src/test/java/io/questdb/test/cairo/view/ViewBootstrapTest.java (4)
31-31: LGTM: Imports support extended test coverage.The new imports are used in the test scenario that validates view behavior when the
tables.dfile is missing (lines 487-490), which is the primary use case this PR addresses.Also applies to: 46-46
339-362: LGTM: Comprehensive view metadata validation.The assertions thoroughly validate view definitions including table IDs, dependencies, and column-level dependencies. The hardcoded table IDs (6, 7) rely on predictable creation order in this isolated test, which is acceptable.
364-384: LGTM: HTTP endpoint validation ensures API stability.The assertion validates the complete JSON response from the
views()endpoint, including schema, dataset, and count. This ensures the API contract is maintained across restarts.
486-555: LGTM: Critical test scenario validates the PR's core fix.This test section addresses the main issue described in the PR: views losing their table ID (defaulting to 0) after restart when
tables.dis absent. The test:
- Removes the
tables.d.0file to simulate the scenario- Restarts QuestDB to trigger table registry reload from the file system
- Re-validates all view metadata to ensure table IDs are correctly derived from directory names
This comprehensive validation ensures the fix works as intended.
All views had their table id set as 0 after a restart without
tables.dfile.When there is no
tables.dfile, we take table id from_metafile.However, views do not have this file.
Table id was defaulted to 0.
Fix is to parse the table id from the table dir name instead of trying to load from
_metafile.required by https://github.com/questdb/questdb-enterprise/pull/850