Skip to content

Isolate writes to the internal system database root.__system - #19017

Merged
JackieTien97 merged 1 commit into
apache:masterfrom
alpass163:cyb/seal_system_db
Oct 26, 2026
Merged

JackieTien97 merged 1 commit into
apache:masterfrom
alpass163:cyb/seal_system_db

Conversation

@alpass163

Copy link
Copy Markdown
Contributor

Description

Motivation

root.__system is maintained by the database itself. In the open-source
version, external clients could write it, delete it, or create it through
SQL. The name was also matched case-insensitively, so root.__System was
treated as the same internal database even though tree-model paths are
case-sensitive.

This PR makes the exact lower-case name reserved and restricts its writes to
dedicated internal writers. Names that differ only in case are ordinary
databases and stay fully usable.

Changes

  • Internal database identification: add InternalDatabaseUtils to
    identify root.__system and the audit databases. Matching is
    case-sensitive and includes descendants (root.__system.x).
  • Internal caller flag: add SessionInfo.internal,
    IAuditEntity.isInternal() and TreeAccessCheckContext.internal. Only
    the internal metric reporter (IoTDBInternalLocalReporter) and the
    internal insert RPC (DataNodeInternalRPCServiceImpl.insertRecord) set
    it. AutoCreateSchemaExecutor now passes the query context instead of a
    bare UserEntity, so the flag survives automatic schema creation.
  • Write guard: add TreeAccessCheckVisitor.checkSystemDatabaseWrite.
    It is applied to inserts, timeseries DDL, template statements, TTL,
    logical view targets and sources, and centrally in
    checkTimeSeriesPermission.
  • View rewrite: AnalyzeUtils and the delete analysis re-check the real
    device paths after a writable view is rewritten, so a view created before
    this restriction cannot write root.__system.
  • LOAD path: AccessControlImpl.checkFullPathWriteDataPermission applies
    the same guard.
  • Database DDL: visitSetDatabase rejects creating root.__system (and
    its descendants) through SQL; visitAlterDatabase and
    visitDeleteDatabase already rejected altering and deleting it.
  • Case-sensitive audit matching: Audit helpers and the direct
    equalsIgnoreCase comparisons in AccessControlImpl,
    ITableAuthCheckerImpl, ClusterConfigTaskExecutor, ConfigManager,
    PartitionInfo and SubscriptionInfo now use equals.
  • Example and documentation: the statistics trigger example writes to
    root.statistics instead of root.__system.statistics, and
    iotdb-system.properties.template states that the IOTDB session metric
    reporter is not supported because its writes are rejected.

@JackieTien97
JackieTien97 merged commit 6b77a8d into apache:master Oct 26, 2026
39 checks passed
VGalaxies pushed a commit to VGalaxies/iotdb that referenced this pull request Oct 29, 2026
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