Skip to content

fix(core): fix for view becomes suspended after it is altered#6623

Merged
bluestreak01 merged 5 commits intomasterfrom
ia_fix_view_suspended
Jan 12, 2026
Merged

fix(core): fix for view becomes suspended after it is altered#6623
bluestreak01 merged 5 commits intomasterfrom
ia_fix_view_suspended

Conversation

@glasstiger
Copy link
Copy Markdown
Contributor

@glasstiger glasstiger commented Jan 9, 2026

When a view was altered, it became suspended because of missing metadata.
This PR fixes the issue by adding the metadata back.

Changed tests (alter view, checkpoint, view replication) to assert that views are not suspended.

We should explore how to get rid of the _meta files completely for views, but the sequencer, the writer, checkpoint/backup and replication all rely on its presence at least to some extent.


required by https://github.com/questdb/questdb-enterprise/pull/853

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 9, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Changes relocate metadata write operation in TableUtils to execute unconditionally for both views and non-views, add suspension validation in view tests, and introduce a new checkpoint recovery test for altered views.

Changes

Cohort / File(s) Summary
Core metadata handling
core/src/main/java/io/questdb/cairo/TableUtils.java
Moved _meta file write outside conditional block to execute for both views and non-views; symbol map creation remains in non-view branch
View test assertions
core/src/test/java/io/questdb/test/cairo/view/AbstractViewTest.java
Added runtime assertion validating table is not suspended before view state retrieval
Checkpoint recovery test
core/src/test/java/io/questdb/test/griffin/CheckpointTest.java
New test method testCheckpointWithViewAlters() verifying checkpoint and recovery behavior with view ALTER operations; added ViewDefinition import

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • bluestreak01
  • jerrinot
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: restoring metadata to prevent views from becoming suspended after alteration.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue (missing metadata causing views to suspend) and the solution (restoring metadata).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@glasstiger
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @core/src/test/java/io/questdb/test/cairo/view/AbstractViewTest.java:
- Around line 142-146: The helper assertViewState should null-check the
TableToken returned by engine.getTableTokenIfExists(name) before calling
engine.getTableSequencerAPI().isSuspended(viewToken); if viewToken is null, fail
the test with a clear message (e.g., "view/table not found: " + name) so the
root cause is exposed, then proceed to call isSuspended(viewToken) and
engine.getViewStateStore().getViewState(viewToken) only when viewToken is
non-null.
🧹 Nitpick comments (1)
core/src/test/java/io/questdb/test/griffin/CheckpointTest.java (1)

999-1044: Tighten test wording + add a null-check for viewToken

  • Line 1032: comment says “dropped view” but the view is altered; this reads like copy/paste and can confuse future readers.
  • Line 1035-1036: add Assert.assertNotNull(viewToken) for clearer failures.
Proposed tweak
-            // the dropped view should be restored
+            // the pre-checkpoint view definition should be restored
 
             final TableToken viewToken = engine.getTableTokenIfExists("v");
+            Assert.assertNotNull(viewToken);
             final ViewDefinition viewDefinition = engine.getViewGraph().getViewDefinition(viewToken);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b33acc9 and f536c05.

📒 Files selected for processing (3)
  • core/src/main/java/io/questdb/cairo/TableUtils.java
  • core/src/test/java/io/questdb/test/cairo/view/AbstractViewTest.java
  • core/src/test/java/io/questdb/test/griffin/CheckpointTest.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-08T21:35:08.739Z
Learnt from: glasstiger
Repo: questdb/questdb PR: 6612
File: core/src/main/java/io/questdb/cairo/TableNameRegistryStore.java:313-325
Timestamp: 2026-01-08T21:35:08.739Z
Learning: In TableNameRegistryStore.java's readTableId() method, NumericException from getTableIdFromTableDir() for view directories is intentionally allowed to propagate and fail database startup. This fail-fast behavior is correct because corrupted view directory names indicate database tampering, and views with table id 0 would not show obvious failures. Regular tables without _meta files return 0 to allow database startup for resilience.

Applied to files:

  • core/src/test/java/io/questdb/test/griffin/CheckpointTest.java
🧬 Code graph analysis (1)
core/src/main/java/io/questdb/cairo/TableUtils.java (1)
core/src/main/java/io/questdb/std/MemoryTag.java (1)
  • MemoryTag (27-184)
⏰ 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 (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 (SelfHosted Other tests on linux-arm64)
  • GitHub Check: New pull request (Rust Test and Lint on linux-jdk17)
  • GitHub Check: New pull request (SelfHosted Other tests on linux-x64-zfs)
  • GitHub Check: New pull request (SelfHosted Griffin tests on linux-x86-graal)
  • GitHub Check: New pull request (SelfHosted Other tests on linux-x86-graal)
  • 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 (SelfHosted Griffin tests on linux-x64-zfs)
  • GitHub Check: New pull request (Hosted Running tests on mac-cairo)
  • GitHub Check: New pull request (SelfHosted Cairo tests on linux-x86-graal)
  • GitHub Check: New pull request (SelfHosted Griffin tests on linux-arm64)
  • GitHub Check: New pull request (SelfHosted Cairo tests on linux-arm64)
  • GitHub Check: New pull request (Hosted Running tests on mac-griffin)
  • GitHub Check: New pull request (SelfHosted Cairo tests on linux-x64-zfs)
  • GitHub Check: New pull request (Trigger Enterprise CI Trigger Enterprise Pipeline)
  • GitHub Check: New pull request (Check Changes Check changes)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (1)
core/src/main/java/io/questdb/cairo/TableUtils.java (1)

576-606: Fix is safe; no code infers view-ness from _meta absence

Views are detected explicitly via TableToken.isView(), the _view definition file marker, or structural metadata. No legacy logic depends on _meta absence for view detection. Writing _meta for views poses no compatibility risk.

@glasstiger
Copy link
Copy Markdown
Contributor Author

[PR Coverage check]

😍 pass : 5 / 5 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/TableUtils.java 5 5 100.00%

@bluestreak01 bluestreak01 merged commit daf6d1c into master Jan 12, 2026
43 checks passed
@bluestreak01 bluestreak01 deleted the ia_fix_view_suspended branch January 12, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants