Skip to content

Apply additive storage changes at boot on BanyanDB, name the storage stage in StorageManipulationOpt, and log every storage resource's outcome in one place - #14276

Merged
wu-sheng merged 1 commit into
masterfrom
boot-additive-schema
Nov 27, 2026
Merged

wu-sheng merged 1 commit into
masterfrom
boot-additive-schema

Conversation

@wu-sheng

@wu-sheng wu-sheng commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Apply additive storage changes at boot on BanyanDB, name the storage stage in StorageManipulationOpt, and log every storage resource's outcome in one place

Boot runs in production with no operator watching, so it applies additive storage changes only and never a breaking one. A runtime-rule hot update has an operator, so a breaking change goes through there only with allowStorageChange=true. Hot update only ever changes MAL measures: LAL rules write into record types defined in code.

Before this change, BanyanDB did not follow that rule at boot. A measure, stream or trace whose model gained a column in an upgrade was left with its old shape, and the metric stayed off, unless the model class carried @BanyanDB.Stream.AllowBootReshape (three record types did). JDBC and Elasticsearch already added columns and fields at boot.

  • If this is non-trivial feature, paste the links/URLs to the design doc. The behaviour is documented in Runtime Rule Hot-Update, under "Why boot applies additive changes only", "What boot does on each storage" and "The schema log".
  • Update the documentation to include this new feature.
  • Tests(including UT, IT, E2E) are added to verify the new feature.

Boot on BanyanDB

An init or default-mode OAP now applies an additive difference to every measure, stream and trace at boot, and refuses a breaking one with an ERROR log; @BanyanDB.Stream.AllowBootReshape is removed.

  • Additive: a new tag or field, and a tag moving between the storage-only and searchable families (a storageOnly flip). An entity tag can't move.
  • Breaking, refused: a dropped or retyped tag or field, or a different entity, sharding key, interval, index mode, or trace-id / span-id / timestamp tag. A refused resource's index rules and binding are left as they are too, so the binding never points at tags the live resource doesn't have.
  • A property is schemaless and takes any change.
  • A resource this boot updated also gets the index rules it newly declares after a rule another model of the group already checked. An unchanged resource stops at that shared rule, as before.
  • Index rules, bindings, TopN aggregations and groups otherwise behave as before. A not-main OAP's startup check and a runtime-rule apply also behave as before.

JDBC and Elasticsearch behave as before. A new column is added to a JDBC table, and appended to an Elasticsearch index. An Elasticsearch template whose mapping, shard / replica settings or order differ is re-put, and the new definition reaches only the indices created after it. The one ordinary index, management (ui_template, continuous_profiling_policy, runtimerule), is never re-created, so it keeps its settings; a settings difference there stays the existing WARN.

StorageManipulationOpt: the stage is in the declaration

The storage policy now says which stage it serves. Stage {BOOT, RUNTIME}; modes BOOT_INSTALL, RUNTIME_APPLY, RUNTIME_PEER_VERIFY, RUNTIME_LOCAL_ONLY; factories bootInstall(), runtimeApply(), runtimeApplyDeferredFence(...), runtimePeerVerify(), runtimeLocalOnly(). The outcomes name what happened: MATCHED, CREATED, UPDATED, DROPPED, BOOT_REFUSED_BREAKING_CHANGE, RUNTIME_PEER_SCHEMA_ABSENT, RUNTIME_PEER_SCHEMA_DIFFERENT, RUNTIME_BACKEND_UNTOUCHED. The SKIPPED_* outcomes are gone.

The class Javadoc maps where each mode runs in an OAP cluster (OAP role and what it is doing → mode → the outcomes it records), and the mode and outcome docs read the same way, for example "OAP (main, applying /addOrUpdate) → ..." then "OAP (not-main, starting up) → ...".

A refusal is checked against the outcomes of the caller's own registration only: MetricsStreamProcessor across all of a metric's downsamplings, and MeterSystem. One opt is shared by a whole MAL file, so an earlier metric's refusal no longer turns off a later one.

One storage schema log

ModelInstaller logs the outcome of every storage resource it checks or changes: a table, an index or template, a BanyanDB group, measure, stream, trace, property, index rule, binding or TopN aggregation. Each line carries the mode and the physical resource name. It logs at DEBUG when the resource is unchanged, at INFO when it was created, updated or dropped, and at ERROR when an incompatible difference was left unapplied. The storage plugins log the DDL they run at DEBUG.

storage schema [BOOT_INSTALL] model [service_cpm]: measure(sw_metricsMinute/service_cpm_minute)=UPDATED[adds tags [layer searchable:TAG_TYPE_STRING]]

Each outcome is recorded where its operation happens. A JDBC table lists the columns and indexes that were added, including when a later statement fails. A BanyanDB measure drop records its TopN aggregations and binding. A not-main OAP's startup check names the table, index, template or group/name it found missing or different.

Verification

  1. Unit tests: the full suite, 5,118 tests, passes. New: JDBCTableInstallerTest and StorageEsInstallerOrdinaryIndexTest. Checkstyle, the license-header check and the full build with the javadoc check pass.
  2. Storage ITs: BanyanDB 194, JDBC on MariaDB and PostgreSQL 515, Elasticsearch / OpenSearch (elastic-it) 1,981, all passing. BanyanDBIT gains boot tests that assert the stored shapes, rules and bindings: an additive measure, stream and trace; a refused measure and stream; a measure that gains a tag after a rule another measure shares; a not-main OAP's check leaving an additive difference alone, and reporting a shared missing rule for each measure; a measure drop. The only other test changes are the mechanical renames.
  3. Upgrade from master: master booted on a fresh storage, then this branch on the same storage, with the schema log at DEBUG, on BanyanDB, MySQL, and Elasticsearch with and without logic sharding (PostgreSQL in an earlier run of the same check). No storage object changed: the dumps after each boot match, server-assigned values included. The new boot logged only MATCHED: on BanyanDB 12 groups, 6,705 measures, 26 streams, 3 traces, 3 properties, 146 index rules, 6,265 bindings and 27 TopN aggregations; on MySQL 6,739 tables; on Elasticsearch the templates and the management index. On Elasticsearch without logic sharding it also logged two UPDATED re-puts of the records-all template, which master does on every boot too.
  4. Additive upgrade: this branch booted, then a build adding one column to AlarmRecord, ServiceTraffic and SegmentRecord, on the same storage. Exactly those resources were updated: on BanyanDB the AlarmRecord stream, the ServiceTraffic measure and the SegmentRecord trace, with their 2 new index rules created and 2 bindings updated; on MySQL the 3 tables; on Elasticsearch the 3 templates and the 3 current indices. Each was logged at INFO, with the DDL at DEBUG.
  5. Schemas on fresh storage: every bundled rule plus verification-only rules covering every OAL and MAL function, booted on the five setups above. The schema objects, metric catalog and raw export are identical to the previous build's (BanyanDB 13,228 objects, MySQL and PostgreSQL 97, Elasticsearch 180 and 22). The model definitions differ only by the removed allowBootReshape.
  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.

  • Update the CHANGES log.

  • GraalVM distro impact:

    • Impacted, by: a class the distro replaces (MeterSystem) and a DSL engine (MeterSystem, MAL, TAL). StorageManipulationOpt's factories and outcomes are renamed: schemaCreateIfAbsent() is now bootInstall(), hasShapeMismatch() is replaced by firstBootRefusalSince(int) (the outcomes of the caller's own call), and SKIPPED_SHAPE_MISMATCH is now BOOT_REFUSED_BREAKING_CHANGE. The distro's MeterSystem replacement and its MeterSystemCreateTest use the old names and need the same change at the next sync. MetricConvert and TALClassGenerator, which the distro's checksums pin, change only in comments and the renamed factory.

@wu-sheng
wu-sheng requested a balanced review from Copilot November 27, 2026 05:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@wu-sheng wu-sheng added this to the 11.2.0 milestone Nov 27, 2026
@wu-sheng wu-sheng added the enhancement Enhancement on performance or codes label Nov 27, 2026
@wu-sheng
wu-sheng force-pushed the boot-additive-schema branch from c03a543 to b0324ef Compare November 27, 2026 06:34
…stage in StorageManipulationOpt, and log every storage resource's outcome in one place

Boot runs unattended in production, so it applies additive storage changes only; a runtime-rule hot update has an
operator, so a breaking change goes through there only with allowStorageChange=true.

- BanyanDB: an init or default-mode OAP applies an additive difference to every measure, stream and trace at boot
  (a new tag or field, a tag moving between families except an entity tag), and refuses a breaking one with an
  ERROR log; a property takes any change. @BanyanDB.Stream.AllowBootReshape is removed. A resource this boot
  updated also gets the index rules it newly declares after a shared one.
- StorageManipulationOpt carries the stage: Stage {BOOT, RUNTIME}; modes BOOT_INSTALL, RUNTIME_APPLY,
  RUNTIME_PEER_VERIFY, RUNTIME_LOCAL_ONLY; outcomes MATCHED, CREATED, UPDATED, DROPPED,
  BOOT_REFUSED_BREAKING_CHANGE, RUNTIME_PEER_SCHEMA_ABSENT, RUNTIME_PEER_SCHEMA_DIFFERENT,
  RUNTIME_BACKEND_UNTOUCHED. The class Javadoc maps where each mode runs in an OAP cluster. A refusal is checked
  against the caller's own outcomes only, so one metric's refusal no longer turns off the next metric of a file.
- ModelInstaller logs each storage resource's outcome with its mode and physical name: DEBUG unchanged, INFO
  created / updated / dropped, ERROR an incompatible difference left unapplied. Storage plugins log their DDL at
  DEBUG. JDBC records the columns and indexes it added, also when a later statement fails; a BanyanDB measure
  drop records its TopN aggregations and binding. JDBC and Elasticsearch DDL is unchanged.
@wu-sheng
wu-sheng force-pushed the boot-additive-schema branch from b0324ef to 3087ce3 Compare November 27, 2026 06:34
@wu-sheng
wu-sheng requested a review from wankai123 November 27, 2026 06:39
@wu-sheng
wu-sheng merged commit 3eeaf89 into master Nov 27, 2026
543 of 549 checks passed
@wu-sheng
wu-sheng deleted the boot-additive-schema branch November 27, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement on performance or codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants