Skip to content

Fixed multiple bugs related to schema#17405

Open
Caideyipi wants to merge 12 commits intomasterfrom
schema_scan
Open

Fixed multiple bugs related to schema#17405
Caideyipi wants to merge 12 commits intomasterfrom
schema_scan

Conversation

@Caideyipi
Copy link
Copy Markdown
Collaborator

Description

As the title said.


This PR has:

  • been self-reviewed.
    • concurrent read
    • concurrent write
    • concurrent read and write
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods.
  • added or updated version, license, or notice information
  • added comments explaining the "why" and the intent of the code wherever would not be obvious
    for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold
    for code coverage.
  • added integration tests.
  • been tested in a test IoTDB cluster.

Key changed/added classes (or packages if there are too many classes) in this PR

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 41.93548% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.63%. Comparing base (77fe3e7) to head (964c1f0).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...ngine/plan/analyze/schema/NormalSchemaFetcher.java 0.00% 6 Missing ⚠️
...nal/metadata/fetcher/TableDeviceSchemaFetcher.java 0.00% 4 Missing ⚠️
...gine/plan/analyze/schema/ClusterSchemaFetcher.java 0.00% 3 Missing ⚠️
...persistence/schema/mnode/impl/ConfigTableNode.java 0.00% 1 Missing ⚠️
...metadata/fetcher/cache/TableDeviceSchemaCache.java 0.00% 1 Missing ⚠️
.../relational/sql/ast/RelationalAuthorStatement.java 0.00% 1 Missing ⚠️
...gine/schemaregion/impl/SchemaRegionMemoryImpl.java 0.00% 1 Missing ⚠️
...ache/iotdb/commons/schema/filter/SchemaFilter.java 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17405      +/-   ##
============================================
- Coverage     39.81%   39.63%   -0.18%     
  Complexity      312      312              
============================================
  Files          5127     5134       +7     
  Lines        346390   346882     +492     
  Branches      44120    44188      +68     
============================================
- Hits         137903   137483     -420     
- Misses       208487   209399     +912     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses multiple schema-related correctness issues across TTL handling, schema plan serialization, schema traversal/iterator lifecycle, relational SQL AST deserialization, and table-device schema caching/invalidation.

Changes:

  • Fixes incorrect counters/state resets (e.g., TTL cache count, schema-region statistics, logical view statistics).
  • Corrects schema iteration and caching behaviors (unpinning skipped cached nodes, table-device schema fetching/grouping, cache invalidation targeting).
  • Resolves various schema/SQL logic bugs (authorization validation, expression deserialization, auto-create filtering, procedure state progression, cached fullPath invalidation).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/ttl/TTLCache.java Resets ttlCount on clear() to keep TTL rule counting consistent after cache resets/snapshot loads.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/filter/SchemaFilter.java Makes filter extraction null-safe to avoid NPEs when traversing filter trees.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/SchemaRegionPlanType.java Changes the plan-type byte for ALTER_ENCODING_COMPRESSOR to avoid a code collision.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/schemafile/WrappedSegment.java Cleans up segment construction signatures and fixes offset shifting logic in removeRecord.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/mnode/iterator/CachedTraverserIterator.java Ensures skipped pinned nodes are unpinned when filtered out.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/mnode/iterator/MemoryTraverserIterator.java Implements the new “release skipped node” hook for memory-backed traversal (no-op).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/mnode/iterator/AbstractTraverserIterator.java Adds a hook to release resources for skipped nodes during traversal.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java Corrects logical view statistics updates to reflect the actual number of created views.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/rescon/MemSchemaRegionStatistics.java Fixes clear() to actually reset view count and clears table-related statistics maps.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/RelationalAuthorStatement.java Fixes DROP_ROLE validation to check the role name, not the user name.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/Expression.java Adds deserialization support for CURRENT_DATABASE and CURRENT_USER expressions.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/TableDeviceSchemaFetcher.java Fixes table device schema fetcher bugs (method naming, per-row database grouping, cache request class relocation).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/TableDeviceSchemaCache.java Fixes column-level invalidation to target the correct (database, table) cache key and annotates table-model API.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/metadata/fetcher/cache/DeviceSchemaRequestCache.java Moves cache class into the fetcher cache package to match new usage/imports.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/NormalSchemaFetcher.java Fixes auto-create filtering logic to keep system OR audit series (instead of accidentally requiring both).
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/ClusterSchemaFetcher.java Same auto-create filtering fix for the clustered schema fetch path.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/table/DeleteDevicesProcedure.java Fixes procedure state transitions during blacklist construction to avoid incorrect looping.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/mnode/impl/ConfigTableNode.java Invalidates cached fullPath when renaming to keep path-derived behavior consistent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 39 to 43
ACTIVATE_TEMPLATE_IN_CLUSTER((byte) 63),
PRE_DELETE_TIMESERIES_IN_CLUSTER((byte) 64),
ROLLBACK_PRE_DELETE_TIMESERIES((byte) 65),
ALTER_ENCODING_COMPRESSOR((byte) 66),
ALTER_ENCODING_COMPRESSOR((byte) 80),

Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

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

Changing ALTER_ENCODING_COMPRESSOR’s planType from 66 to 80 fixes the duplicate-code issue with CREATE_LOGICAL_VIEW(66), but it doesn’t address clusters that may already have WAL/consensus logs containing the legacy value 66 for ALTER_ENCODING_COMPRESSOR: those entries will still be deserialized as CREATE_LOGICAL_VIEW and likely fail recovery. Consider adding backward-compatible deserialization for the legacy encoding (e.g., when code==66, peek the next serialized field to distinguish PlanNodeType.ALTER_ENCODING_COMPRESSOR vs logical-view payload) or otherwise provide an explicit migration/guard to prevent startup failures on upgrade.

Copilot uses AI. Check for mistakes.
public void clear() {
ttlCacheTree.removeAllChildren();
ttlCacheTree.addChild(IoTDBConstant.MULTI_LEVEL_PATH_WILDCARD, Long.MAX_VALUE);
ttlCount = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add some comments

PRE_DELETE_TIMESERIES_IN_CLUSTER((byte) 64),
ROLLBACK_PRE_DELETE_TIMESERIES((byte) 65),
ALTER_ENCODING_COMPRESSOR((byte) 66),
ALTER_ENCODING_COMPRESSOR((byte) 80),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add UT

Comment on lines +161 to +166
case 29:
expression = new CurrentDatabase();
break;
case 30:
expression = new CurrentUser();
break;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to do so, it won't be deserialized, if so, it's a bug, we need it to go to default branch and throw execption

@Override
public void setName(final String name) {
tableNodeInfo.setName(name);
this.fullPath = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add some comments about why you need to set it to null

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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