Skip to content

fix(#12234): label the dictionary of a database that writes fixed-width float arrays, so an older build refuses it instead of losing arrays - #12239

Merged
lvca merged 4 commits into
ArcadeData:mainfrom
shaunpatterson:fix/12234-dictionary-rollback-fence
Nov 18, 2026
Merged

lvca merged 4 commits into
ArcadeData:mainfrom
shaunpatterson:fix/12234-dictionary-rollback-fence

Conversation

@shaunpatterson

@shaunpatterson shaunpatterson commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #12234.

Since 26.11.1, ARRAY_OF_FLOATS / ARRAY_OF_DOUBLES values (vector embeddings included) are written in the fixed-width form, binary types 36 and 37 (#10856, PR #10904). A build before 26.11.1 cannot decode them. Opening such a database, 26.10.x and 26.9.1 do not refuse it: they read those arrays as null, leave the records out of vector.neighbors(), and the first UPDATE of such a record rewrites it without its arrays (#12234).

Every build from 26.8.1 on already refuses, at open, a dictionary file labelled with a format version above 1:

Dictionary '.../dictionary.0.65536.v2.dict' was written with format version 2, which this version of ArcadeDB cannot read (latest known is 1)

(Dictionary load constructor, added with multi-page dictionaries in 7c40815, released in 26.8.1.) Every database has exactly one dictionary, and its version lives in the file name.

This PR uses that check as a rollback fence. The mechanism below is the one in the branch after the maintainer commit 405e4d3 and its follow-up; the first version of this PR applied the label lazily, on the first fixed-width value written or decoded.

  • Dictionary.FIXED_WIDTH_FLOAT_ARRAYS_VERSION = 2: byte for byte the same file as version 1. This build reads versions up to 2.
  • The label follows the setting arcadedb.serializer.fixedWidthFloatArrays (default true), not the content. While it is on, a database opened read-write is labelled 2: a new database is created with the label, an existing one is relabelled when it opens (Dictionary.fenceFixedWidthFloatArrays(): rename, then fsync of the directory), and a live one when the setting is turned on (ALTER DATABASE, and the replicated configuration entry on every replica). That includes a database that holds no float or double array.
  • Why not on the first value: a replica receives the form as pages and never serializes it, and vector search reads vectors without the serializer, so a label tied to a value written or decoded left such a node on label 1 while holding types 36/37, and a rollback of that node lost the arrays as in the issue. The same held for a database written by 26.11.x and only searched or appended to after the upgrade. Whether a database holds the form cannot be told without reading every record.
  • The serializer writes the fixed-width form only when the database carries the label (one volatile flag on the write path; the decode path is unchanged). If the relabel fails (I/O error), a WARNING is logged and arrays are written in the varint form, which every build reads, until the next open. The fence never fails an open or a write.
  • A database opened read-only is never relabelled.
  • arcadedb.serializer.fixedWidthFloatArrays=false (exists since 26.11.1) keeps the varint form and label 1: the way to keep a rollback possible. It has to be set before the database is first opened read-write by this build. Turning it off later does not remove the label.
  • HA: the setting is replicated, so every node of this build carries the same label. Nodes of different builds can hold the same bytes under labels 1 and 2 during a rolling upgrade, so /api/v1/cluster/checksums (SnapshotManager.computeFileChecksums), the verify handler (PostVerifyDatabaseHandler) and BootstrapFingerprint report a dictionary labelled 2 under label 1, the name a build without the fence reports. Labels 0 and 1 are reported as they are (a dictionary created before 26.8.1 is labelled 0, and still compares as a different name against a relabelled copy).
  • PaginatedComponentFile.rename() keeps the file open while its name changes: the page flush and the page snapshot read isOpen() without the channel lock, and a committed dictionary page queued for flush during the relabel of a live database was dropped.

Trade-off (needs the maintainer's sign-off at merge)

With the setting on, which is the default, no released build opens a database once this build has opened it read-write: 26.8.1 to 26.11.x refuse it with the message above, whether or not it holds a float array. An upgrade is a one-way door unless the setting is turned off first. This includes 26.11.x, which can decode the fixed-width form but checks the same version > 1. Builds before 26.8.1 do not check the dictionary version and still open it (same silent loss as today).

  • To keep a rollback possible: arcadedb.serializer.fixedWidthFloatArrays=false before the first read-write open by this build (or a backup taken before the upgrade).
  • Recovery, on 26.11.x only (it decodes the form): with the server stopped, rename dictionary.<id>.<pageSize>.v2.dict back to .v1.dict. Never for 26.10.x or older when the database may hold float arrays: that is the data loss of the issue.
  • Rolling upgrade: a node still on an older build that has to install a full snapshot from an upgraded node receives the dictionary under label 2 and refuses it until it is upgraded.

Measured

Database created by arcadedata/arcadedb:26.10.1 (rows 0-2), rows 3-5 with float arrays written by this branch's engine (embedded), then each released image opens the same volume:

opened by before this PR (main 1541bf7 writes rows 3-5) with this PR
26.10.1 opens; rows 3-5 emb = null; UPDATE of row 4 erases its arrays refuses: DatabaseMetadataException: Dictionary '.../dictionary.0.65536.v2.dict' was written with format version 2, which this version of ArcadeDB cannot read (latest known is 1)
26.9.1 same as 26.10.1, CHECK DATABASE 0 errors refuses, same message
26.11.1 opens, reads every row refuses, same message (the trade-off above)
this branch reads every row reads every row (0-5)

(A server holding the database fails to start with that exception, as 26.10.1 already does for a database created by 26.11.1 because of the hash index page layout.)

Tests

  • FixedWidthFloatArraysRollbackFenceTest (engine, 12 tests): a new database is created with label 2; a label 1 database is relabelled by its read-write open alone, with or without arrays in it; with the setting off the label stays 1 and arrays stay varint; turning the setting on relabels before the next array is written; turning it off keeps the label; a relabel that fails keeps label 1 and the varint form until the next open; a read-only open does not relabel; a live relabel under concurrent writers and readers; a name registered right before a live relabel survives a reopen. With the fence disabled, 8 of the 11 tests written first fail (the no-array case was added after that run).
  • BootstrapFingerprintTest: the same dictionary bytes under labels 1 and 2 give the same fingerprint, other bytes do not.
  • PaginatedComponentFileRenameConcurrencyTest: isOpen() stays true through a rename.
  • DictionaryLabelChecksumsTest (ha-raft): the same dictionary bytes under labels 1 and 2 give equal checksum maps, keyed under label 1; different bytes still differ; a dictionary relabelled while a snapshot window is open is still checksummed.
  • Engine module, mvn -o -pl engine -am test -DexcludedGroups=benchmark,slow,vector: 27,711 tests, 4 not passing, all in CypherCallInTransactionsOnErrorIssue11595Test (3 errors) and ParallelSafeExpressionsStateTest (1 failure), which fail the same way on main.
  • ha-raft checksum, bootstrap and capability unit tests (256) and the integration module's backup and restore tests (124): all pass.

…width float array, so a build that cannot read the form refuses the database

Every build from 26.8.1 on refuses at open a dictionary file labelled above
format version 1. Before a record stores its first float or double array in
the fixed-width form (binary types 36/37, ArcadeData#10856), the database relabels its
dictionary file v2 (same bytes) and fsyncs the directory; decoding such a value
relabels a v1 dictionary too (databases written by 26.11.x, HA replicas). A
relabel failure falls back to the varint form. HA checksum maps key a
dictionary without its label. Trade-off: 26.11.x refuses such a database as
well; arcadedb.serializer.fixedWidthFloatArrays=false keeps a rollback possible.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 14 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c26f442e-2ad1-4e30-a873-7cf8b0f28611
Commits

Reviewing files that changed from the base of the PR and between 8af0b3f and e6a1b05.

Files selected for processing: 12

  • engine/src/main/java/com/arcadedb/GlobalConfiguration.java
  • engine/src/main/java/com/arcadedb/database/BootstrapFingerprint.java
  • engine/src/main/java/com/arcadedb/database/LocalDatabase.java
  • engine/src/main/java/com/arcadedb/engine/Dictionary.java
  • engine/src/main/java/com/arcadedb/engine/PaginatedComponentFile.java
  • engine/src/main/java/com/arcadedb/serializer/BinarySerializer.java
  • engine/src/test/java/com/arcadedb/database/BootstrapFingerprintTest.java
  • engine/src/test/java/com/arcadedb/engine/PaginatedComponentFileRenameConcurrencyTest.java
  • engine/src/test/java/com/arcadedb/serializer/FixedWidthFloatArraysRollbackFenceTest.java
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/PostVerifyDatabaseHandler.java
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/SnapshotManager.java
  • ha-raft/src/test/java/com/arcadedb/server/ha/raft/DictionaryLabelChecksumsTest.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@mergify

mergify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@codacy-production

codacy-production Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 20 complexity

Metric Results
Complexity 20

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions github-actions Bot added engine Core engine: document/schema API ha High availability / replication (Raft) has-issue The PR links an issue it resolves severity:critical Data loss, corruption, crash/hang, security hole, or product unusable storage Storage/paging/WAL engine layer triage:needs-changes PR triage: the PR needs changes before it can merge vector Vector index and embedding search labels Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Triage: triage:needs-changes · severity:critical · areas: engine, storage, ha, vector · has-issue

Summary

The approach is sound. It reuses the existing version > 1 refusal in Dictionary as a rollback fence, relabels the dictionary before the first fixed-width float or double array is committed, falls back to the varint form if the rename fails, and never relabels a read-only open. I read PaginatedComponentFile.rename (engine/src/main/java/com/arcadedb/engine/PaginatedComponentFile.java:395). It takes the channel write lock and reopens the file, so the runtime rename looks safe. I found no security problem. The fix targets silent data loss (#12234, critical).

Requested changes

  1. Missing tests for the paths that carry the risk. FixedWidthFloatArraysRollbackFenceTest covers the happy path, the disabled setting, and relabel-on-read. These are not covered:

    • Rename failure. The varint fallback and the WARNING are the "fence never fails a write" guarantee, and nothing exercises them. Make fenceFixedWidthFloatArrays fail, for example with a read-only directory or an injected failure, and assert the value is written as a varint and the dictionary stays at v1.
    • Read-only open. The PR says a read-only open never relabels, and no test checks it. Open a v1 dictionary holding fixed-width records read-only, read them, and assert the file name is unchanged.
    • Concurrency. Several threads commit their first float array at the same time, and a reader decodes while the writer relabels. fenceLock and the volatile flag are only verified by reasoning.
    • Existing files. An existing database that already has records under a v1 label, and a database reopened after the rename, should still work with their indexes and with HA snapshot install. DictionaryLabelChecksumsTest only tests the checksum key, not a real v1 to v2 relabel between nodes.
  2. Read-path side effect. deserializeValue now calls fixedWidthFloatArraysFence.getAsBoolean() and discards the result. A read can therefore trigger a file rename and fsync, on the first decode of a v1 database written by 26.11.x. Please:

    • Make the intent explicit with a named method such as ensureFenced(), not a discarded boolean.
    • Confirm this cannot run while the decoding thread holds a page or file lock that rename also needs (a lock-order deadlock).
    • Add a test for a read inside an open transaction and for an index or vector scan.
  3. Maintainer sign-off on the trade-off. After the first fixed-width value, rollback to 26.11.x is refused, where today it works. The PR describes this clearly, but it is a product decision. It should be recorded in the release notes or docs, not only in the setting description.

  4. Smaller points.

    • Dictionary.comparableFileName calls String.replaceFirst, which compiles a regex, once per file on every checksum computation. Use a precompiled Pattern constant, or a plain lastIndexOf parse.
    • Don't collapse FIXED_WIDTH_FLOAT_ARRAYS_VERSION and LATEST_READABLE_VERSION into aliases unless there is a reason to keep both. At minimum, keep the field declarations in the file's existing order.
    • The PR notes that ReplicatedApplyPublicationTest failed 4 times in 9 runs on this branch and 0 times in 8 on main, with the cause attributed to host load. Please re-run it on an idle machine to rule out an interaction with the new rename on the replica apply path.

@robfrank robfrank added the needs-changes review-pr label Nov 16, 2026
@robfrank

Copy link
Copy Markdown
Collaborator

Automated review: changes needed

fixer reply invalid. The contributor has findings to address.

Why: The PR needs changes: the GitHub triage or the tests found problems the automated fixer could not resolve.

Next step: Read the latest classify-pr triage comment on this PR and address its findings.

Step Result
Triage clean
GitHub triage NEEDS_CHANGES
Sandbox build and tests on d0710ea090bd3d2639835e01d5aec4028c403aab not run
Fix commits pushed none

GitHub triage findings: see the latest classify-pr triage comment on this PR.

…eued for flush, and the review's gaps are tested

The relabel renames the dictionary file. PaginatedComponentFile.rename() went through close(), which clears
`open`, and PageManager.flushPage() and the page snapshot read isOpen() without the channel lock. A dictionary
page committed just before the relabel (a new property name in the same record as the first embedding) was
then flushed against a "closed" file and lost: after a reopen the name was gone and its id was handed to the
next new name. rename() now swaps the channel without ever reporting the file closed.

- SnapshotManager: the window's files are matched by the comparable name, so a dictionary relabelled after t0
  is not taken for a page file created after t0 and left out of the checksums
- the fence latches a failed relabel until the next open instead of retrying a rename per float array
- BinarySerializer: the read-path call is a named ensureFixedWidthFloatArraysFenced(), with the lock-order
  reasoning
- Dictionary.comparableFileName() parses without a regex; field declarations back in their original order
- tests: relabel failure (varint fallback, version 1 kept, latch), read-only open, indexed read inside a
  transaction on an existing 26.11.x database, concurrent first writers and readers, a name registered right
  before the relabel surviving a reopen, isOpen() through a rename, checksums under an open window

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot removed the triage:needs-changes PR triage: the PR needs changes before it can merge label Nov 17, 2026
@robfrank

Copy link
Copy Markdown
Collaborator

Changes for the classify-pr triage on d0710ea are in 743c5f2. There were no inline threads, and CodeRabbit hit its rate limit without posting a review.

A data-loss bug the new concurrency test found (not in the triage). PaginatedComponentFile.rename() went through close(), which clears open. PageManager.flushPage() and PageManager.openSnapshot() read isOpen() without the channel lock. A dictionary page committed just before the relabel was flushed against a file that looked closed and was dropped ("Cannot flush pages on disk because file ... is closed"). The common first write after an upgrade hits this: a record that adds a new property name and an embedding. After a reopen the name was gone and its id went to the next new name, so every record holding it decoded under the wrong name. A reproduction loop failed 5 of 40 runs on this branch and 0 of 40 on the base. rename() now swaps the channel without ever reporting the file closed. Both regression tests fail on every run with the old rename() and pass with the fix: PaginatedComponentFileRenameConcurrencyTest.isOpenStaysTrueThroughoutARename and FixedWidthFloatArraysRollbackFenceTest.aNameRegisteredRightBeforeTheRelabelSurvivesAReopen. The Dictionary javadoc saying "needs no flush barrier" is now accurate, and it says why.

Second finding from the same review. SnapshotManager.computeFileChecksums(dir, snapshot) matched the window's files by name. A dictionary relabelled after t0 looked like a page file created after t0, so it was left out of the checksums. The window's files are now keyed by Dictionary.comparableFileName. Test: DictionaryLabelChecksumsTest.aDictionaryRelabelledWhileASnapshotIsOpenIsStillChecksummed, which fails before the fix.

# Finding Outcome
1a Rename failure: varint fallback, WARNING, dictionary stays v1 Fixed in 743c5f2. aRelabelThatFailsWritesTheVarintFormAndKeepsVersion1 puts a directory at the target name. It asserts the varint size, label 1, and that the values read back. A failed relabel used to retry a close+move+reopen of the dictionary under its write lock on every float array. It is now latched until the next open, with one WARNING. The test checks the latch and the retry after a reopen.
1b Read-only open never relabels Fixed in 743c5f2. aReadOnlyOpenDecodesTheFixedWidthFormWithoutRelabelling uses a v1 dictionary holding fixed-width records, opens it read-only, reads it by RID and by SQL, and asserts the label is still 1.
1c Concurrency Fixed in 743c5f2. concurrentFirstWritesAndReadsRelabelOnce runs 4 writers committing their first fixed-width values and 4 readers decoding the form under the v1 label while it changes. It checks every value after a reopen. This test exposed the bug above.
1d Existing v1 database with indexes, reopen; HA snapshot install between nodes Engine side fixed in 743c5f2. anIndexedReadInsideATransactionRelabelsAnExistingDatabase starts from an existing 26.11.x-labelled database with an LSM index. It does an index lookup inside an open transaction (which relabels), a write in the same transaction, a reopen, a lookup of every key, and an index entry count. HA: covered by the snapshot-window checksum fix and test above, not by a multi-node relabel IT. A snapshot install swaps the whole database directory, so a follower never keeps its own label next to the leader's file. Nodes holding the same bytes under two labels only matter to checksum comparison, which DictionaryLabelChecksumsTest covers.
2 Read-path side effect Fixed in 743c5f2. The discarded boolean is now ensureFixedWidthFloatArraysFenced(), and its javadoc gives the lock order. The relabel takes only the dictionary's fence monitor and that file's channel write lock. A decoding thread never holds the channel lock, because it is held only inside one page read or write, which never decodes a record. So the relabel cannot deadlock against the read that triggers it. The read inside a transaction and the index scan are tested (1d).
3 Product sign-off on refusing rollback to 26.11.x Not code. Left for the maintainer to record in the release notes.
4a comparableFileName regex per file Fixed in 743c5f2. It is now a lastIndexOf parse with no regex, and comparableFileNameDropsOnlyADictionaryLabel covers the edge cases (v, vx, v12, unlabelled, non-dictionary, null).
4b FIXED_WIDTH_FLOAT_ARRAYS_VERSION / LATEST_READABLE_VERSION aliases, field order Both kept, and the javadoc now gives the reason. The first says what label 2 means and never changes. The second is the refusal threshold and moves with the next label. DICTIONARY_HEADER_SIZE is back right after CURRENT_VERSION, and fenceLock is with the instance fields. Fixed in 743c5f2.
4c Re-run ReplicatedApplyPublicationTest 10 of 10 green on 743c5f2 (21 tests each), at load average about 7. That is not idle, so the earlier 4 in 9 does not reproduce here. The dropped-flush window fixed above is a plausible contributor, because that test applies pages while the dictionary can be relabelled.

Tests run on 743c5f2:

  • engine: com.arcadedb.serializer.**, Dictionary*, PaginatedComponent*, ReplicatedApplyPublicationTest, *Rename*, *ReadOnly*, *Snapshot*: 645 tests, 0 failures
  • ha-raft: DictionaryLabelChecksumsTest, Issue6116ChecksumsPointInTimeTest, Issue7338*, Issue8018*, Issue9638*, Issue9751*, PostVerifyDatabaseHandler*Test, SnapshotManagerTest: 70 tests, 0 failures
  • FixedWidthFloatArraysRollbackFenceTest 5 runs in a row, and its concurrency test plus the reproduction loop 320 times: all green

@github-actions github-actions Bot added the triage:needs-changes PR triage: the PR needs changes before it can merge label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Triage: triage:needs-changes · severity:critical · areas: engine, storage, ha · has-issue

Review of #12234 (dictionary relabel as a rollback fence)

I found no security hazard in the diff. The approach is clever and the tests are thorough. Four points need a maintainer decision or a change before merge.

1. The trade-off needs explicit maintainer sign-off.

  • After the first fixed-width array, 26.8.1 through 26.11.x refuse to open the database. A rollback to 26.11.x that works today for such a database would become a refusal.
  • That is a deliberate compatibility break. It is the only mechanism available, but it needs a decision from the owners and a release note. It also needs a documented recovery path for users who hit it, for example renaming the .v2.dict file back to .v1.dict when the build can decode the form.

2. A live rename of a component file is the riskiest part.

  • The old Dictionary Javadoc said renaming a live component file needs PaginatedComponent#rename behind a full flush barrier, and that it would race replication shipping pages by file id. This PR removes that note and skips the barrier.
  • The argument rests on PaginatedComponentFile.rename holding the channel write lock while open stays true. Please confirm that nothing caches the file path or name outside that lock. Candidates are backup and restore, the HA snapshot or file-list shipping in ha-raft, LocalSchema file registration, and PageSnapshot and NodeLocalFiles.
  • The ha-raft changes cover only the checksum paths. Please check that the install-snapshot and file-copy flows tolerate a .v1 and .v2 mismatch between nodes mid-transfer, or add a test that does.
  • PaginatedComponentFileRenameConcurrencyTest covers isOpen. A test that renames the dictionary while a backup or a replication snapshot is running would give more confidence.

3. Decoding a value now has a side effect.

  • BinarySerializer.deserializeValue calls ensureFixedWidthFloatArraysFenced(). It can trigger a file rename, a directory fsync and an INFO log from inside any read path, including reads inside transactions and under page locks.
  • The Javadoc argues this cannot deadlock. Please back that up with a test that decodes while holding the dictionary or page locks (partly covered by concurrentFirstWritesAndReadsRelabelOnce).
  • The read-only mode check is good.
  • Consider moving the "relabel on read" step to database open, for example by scanning the dictionary or a flag. That would avoid I/O in the decode hot path.

4. Minor points.

  • On the hot path storageTypeOf now makes two volatile reads and two supplier calls per float array. This is probably fine, but cache the fenced state in a field if profiling shows a cost.
  • LocalDatabase.fenceFixedWidthFloatArrays latches a failure until reopen. Writes then silently use the varint form, which is safe. Consider exposing that state, for example in CHECK DATABASE or the metrics, so operators notice.
  • The PR body notes that ReplicatedApplyPublicationTest failed 4 of 9 times on this branch. Please re-run it on a quiet host to rule out an interaction with the PaginatedComponentFile change.

The tests follow the project style (AssertJ, reopen, concurrency, HA checksum equivalence). There are no unrelated changes. The PR comes from a fork and a CONTRIBUTOR, so the engine team should review the rename and the replication interplay with extra care.

@lvca lvca self-assigned this Nov 17, 2026
@lvca lvca added this to the 26.12.1 milestone Nov 17, 2026
…pen, instead of the first value written or decoded

The fence of the previous two commits relabelled the dictionary lazily: on the first fixed-width float array
serialized, and on the first one decoded through BinarySerializer.deserializeValue. The label is the right
mechanism (it is the only check 26.8.1 to 26.10.2 all enforce), but tied to a value it was not deterministic:

- a replica receives the form as pages and never serializes it. It relabelled only if it happened to decode such
  a value, so a node that only applied pages, or only answered vector searches (StoredVectorReader does not go
  through deserializeValue), kept label 1 while holding types 36/37. Rolled back, it lost the arrays as before.
  The same held for a database written by 26.11.x and only searched or appended to after the upgrade
- a read had a side effect: a rename, a directory fsync and a channel reopen under the dictionary's channel write
  lock, from whatever thread decoded the first array, plus a supplier call per array decoded on a full scan

Now a read-write database is labelled while arcadedb.serializer.fixedWidthFloatArrays is on: a new database is
created with the label, an existing one is relabelled when it opens, and a live one when the setting is turned
on (ALTER DATABASE, or the replicated configuration entry on every replica). The setting is replicated, so the
label is the same on every node of a build that knows it. The serializer reads one volatile flag, on the write
path only; the decode path is untouched. A relabel that fails keeps the varint form until the next open, as
before, without a latch: nothing retries per value any more.

Also:
- BootstrapFingerprint hashed the dictionary's file name, so two peers staged from the same files read as
  mismatched at cluster formation as soon as one had relabelled its copy
- Dictionary.comparableFileName folds a relabelled dictionary back to label 1 instead of dropping the label. A
  peer of a build without the fence reports the name with its label, so the label-less key made every
  mixed-version comparison (VERIFY DATABASE, the checksum maps) report the dictionary missing on both sides.
  Labels 0 and 1 are reported as they are, so nothing changes for a database that is not relabelled. The
  snapshot window matches its own file across a relabel with unlabelledFileName, whatever label it had

The PaginatedComponentFile.rename change (the file stays open through a rename) is kept: the relabel of a live
database still needs it.

Trade-off, unchanged in kind and wider in reach: with the setting on, 26.8.1 to 26.11.x refuse the database from
its first read-write open by this build, whether or not it holds a float array. Setting
arcadedb.serializer.fixedWidthFloatArrays=false before that open keeps the files openable by an older build.
@lvca

lvca commented Nov 17, 2026

Copy link
Copy Markdown
Member

Thanks for this fix: the dictionary label is the right mechanism, it is the only check every build from 26.8.1 to 26.10.2 already enforces, and the PaginatedComponentFile.rename finding (a page queued for flush dropped while the file reported itself closed) is a real defect of its own. I pushed one commit on top of yours that keeps both and changes WHEN the label is applied.

What changed, and why

The label was applied lazily, on the first fixed-width array serialized and on the first one decoded through BinarySerializer.deserializeValue. Tied to a value, it was not deterministic:

  • A replica receives the form as pages and never serializes it. It relabelled only if it happened to decode such a value, so a node that only applies pages, or only answers vector searches (StoredVectorReader does not go through deserializeValue), stayed on label 1 while holding types 36/37. Rolled back, it lost the arrays exactly as in the issue. Same for a database written by 26.11.x and only searched or appended to after the upgrade.
  • A read had a side effect: a rename, a directory fsync and a channel reopen from whatever thread decoded the first array, plus a supplier call per array on every scan.

Now the label follows the setting. While arcadedb.serializer.fixedWidthFloatArrays is on, a read-write database is labelled: a new one is created with label 2, an existing one is relabelled when it opens, and a live one when the setting is turned on (ALTER DATABASE, and the replicated configuration entry on every replica). The serializer reads one volatile flag on the write path; the decode path is back to what it was. A relabel that fails still falls back to the varint form until the next open, with no per-value retry and no latch.

Also in the commit:

  • BootstrapFingerprint hashed the dictionary's file name, so two peers staged from the same files read as mismatched at cluster formation as soon as one had relabelled.
  • Dictionary.comparableFileName now folds a relabelled dictionary back to label 1 instead of dropping the label. A peer of a build without the fence reports the name with its label, so the label-less key made every mixed-version comparison report the dictionary missing on both sides. Labels 0 and 1 are reported unchanged.

On the review points

  • Live rename and name caches: the snapshot ship reads names and content from the t0 window by file id, so a relabel mid-transfer ships the t0 name and the follower relabels at its own open. The live rename now happens only on a configuration change, not on a record path.
  • Decode side effect, hot-path cost, latch: gone with the redesign.
  • Not changed: binary types 32 to 35 (26.10.2) have the same exposure against 26.10.1 and 26.9.1 and are outside this fix.

The trade-off, for the release notes

With the setting on (the default), 26.8.1 to 26.11.x refuse a database from its first read-write open by 26.12.1, whether or not it holds a float array. That includes 26.11.x, which can decode the form.

  • To keep a rollback possible, set arcadedb.serializer.fixedWidthFloatArrays=false before the database is first opened by 26.12.1.
  • Recovery on 26.11.x only (it decodes the form): stop the server and rename dictionary.<id>.<pageSize>.v2.dict back to .v1.dict. Never do that for 26.10.x or older when the database may hold float arrays, that is the data loss of the issue.
  • Rolling upgrade: a node still on an older build that has to install a full snapshot from an upgraded node receives the dictionary under label 2 and refuses it until it is upgraded too.

@github-actions

Copy link
Copy Markdown
Contributor

Triage: triage:needs-changes · severity:critical · areas: engine, storage, ha, vector · has-issue

Review of #12239

The fence idea is sound. It reuses the existing version > 1 refusal in older builds, so they refuse a database instead of silently dropping float arrays. I rate the severity severity:critical, following #12234, because the bug it fixes is silent data loss.

Blocking: the diff does not do what the description says

The PR body says the dictionary is relabelled before a record stores its first fixed-width array, and that a failed relabel makes the serializer write varint. The code does something broader:

  • LocalDatabase.fenceFixedWidthFloatArrays() runs from openInternal() and configurationChanged(). It relabels the dictionary to v2 whenever the database opens read-write and arcadedb.serializer.fixedWidthFloatArrays is true.
  • That setting defaults to true (GlobalConfiguration.java). So every read-write database opened by this build becomes v2, including databases that never hold a float or double array.
  • The test at about line 567 of the diff says "relabelled by the open alone".
  • The PR body says "a database without float arrays stays v1", and the Dictionary Javadoc says "before the first value". Neither matches the code.
  • The first-open relabel is a much larger trade-off than the one the description presents. After this build touches a database once, no released build can open it, and every upgrade becomes a one-way door. That affects all users, not only vector users.

Please decide which behaviour is intended, then make the code, tests, Javadoc and PR body agree.

  • If the narrow, lazy fence is intended (my recommendation), relabel only when a fixed-width value is about to be written, or when one is decoded under a v1 label. Keep the serializer's varint fallback if the relabel fails.
  • If relabelling at open is intended, say so plainly in the PR body and the setting description. Get maintainer sign-off on making every database unopenable by older builds. Add a test that a database with no arrays is relabelled.

Also, Dictionary(database, name, filePath, mode, pageSize) now creates new databases as v2 when the setting is true. This contradicts "New databases are still created as version 1" in the body.

Other points

  • Rename path: PaginatedComponentFile.rename() now keeps open=true while the channel is swapped. The concurrency argument is plausible, but please check that nothing reads file/channel without channelLock. In the failure path, open=false is set after a failed reopen, so the file really is closed; confirm callers handle that. The added test in PaginatedComponentFileRenameConcurrencyTest is good.
  • Rename durability: FileUtils.forceDirectory can fail after the rename has succeeded. The code then logs a warning and the fence is treated as not applied, while the file is already v2. Handle this case, for example by re-reading the label from the file.
  • Checksum/fingerprint comparison: comparableFileName folds every label of 2 or above to .v1. It is used in BootstrapFingerprint, SnapshotManager.computeFileChecksums and PostVerifyDatabaseHandler. That is reasonable, but it changes the fingerprint input. Mixed-version rolling upgrades need either a test or a note that a v0 versus v1 mismatch still shows up.
  • Setting description: it is very long. Move the explanation into the docs and keep the setting description short.
  • Style: Javadoc is thorough but the comments are very verbose. This is minor.
  • Tests: coverage is good (engine fence test, rename concurrency, HA checksum test). The ReplicatedApplyPublicationTest failures you report are probably unrelated, but please confirm that with a clean run. Once the behaviour is settled, add a test for whichever lazy or eager contract you pick.

…open too, and the setting says so in fewer words

The label follows the setting, not the content: state it with a test of a label 1 database that holds no float
or double array. The description of arcadedb.serializer.fixedWidthFloatArrays is cut to what an operator needs:
what the label does, and that the setting has to be off before the first read-write open to keep a rollback.
@lvca lvca changed the title fix(#12234): relabel the dictionary before the first fixed-width float array, so an older build refuses the database instead of losing arrays fix(#12234): label the dictionary of a database that writes fixed-width float arrays, so an older build refuses it instead of losing arrays Nov 17, 2026
@github-actions github-actions Bot added triage:needs-changes PR triage: the PR needs changes before it can merge and removed triage:needs-changes PR triage: the PR needs changes before it can merge labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Triage: triage:needs-changes · severity:critical · areas: engine, storage, ha · has-issue

Thanks for the thorough write-up and the tests. I reviewed this from the PR description and a quick scan of the diff, not a line-by-line read, so treat the points below as the main blockers.

Severity: I kept severity:critical from #12234. Older builds silently lose float arrays, which is data loss.

Blocking: the default makes the upgrade a one-way door.

  • With arcadedb.serializer.fixedWidthFloatArrays=true (the default), this build relabels the dictionary of every database it opens read-write, even one that holds no float arrays.
  • After that, no released build can open the database. 26.8.1 to 26.11.x all refuse it, including 26.11.x, which can decode the fixed-width form.
  • Your own description says this needs the maintainer's sign-off. A maintainer has to explicitly accept the trade-off, or the default and rollout have to change, before merge.
  • One option is to keep label 1 by default and only relabel when fixed-width arrays are actually enabled or written. The catch is that your own analysis shows replicas and vector-only paths can hold types 36/37 without ever writing them, so that option needs a safe answer for those cases.

Risk areas that need a maintainer's careful review:

  • The rename of the live dictionary file is a risky change. PaginatedComponentFile.rename() now keeps the file open during a rename, to avoid dropping queued page flushes. Please confirm that reads and flushes are safe against the changed channel and name state, and that a crash between the rename and the directory fsync leaves a database that opens.
  • HA checksum normalization reports label 2 as label 1 in SnapshotManager, PostVerifyDatabaseHandler and BootstrapFingerprint. That hides a real file-name difference during rolling upgrades.
    • A node that is not upgraded and installs a full snapshot from an upgraded node will refuse the dictionary.
    • Please document this in the upgrade notes, or add a capability or version check so the snapshot is not offered to older nodes.
  • The write path now depends on a volatile flag. Please confirm that the flag is set only after the rename has succeeded, and that the fallback to varint on a failed relabel cannot produce mixed forms under a label of 1. Mixed forms are safe only because every build decodes varint.

Conventions:

  • Please add a note about the one-way door and the =false escape hatch to the release or upgrade documentation.
  • Please check that the new tests are not wall-clock sensitive, since the concurrency tests run writers and readers, and that none of them binds a hard-coded port.
  • Dictionary, PaginatedComponentFile and BinarySerializer are hot paths. Please confirm the single volatile read on the write path is the only added cost.

@lvca

lvca commented Nov 17, 2026

Copy link
Copy Markdown
Member

On the review of e6a1b05:

  • One-way door: this is the open decision, and it is the maintainer's to take at merge. The alternative the review names (label only when a fixed-width array is written or decoded) is what the first two commits did, and it leaves the nodes that hold types 36/37 without ever serializing them (a replica applying pages, a node answering vector searches, a database written by 26.11.x) on label 1, which is the data loss of Rollback after an upgrade: 26.10.x and 26.9.1 open a database holding float arrays written by 26.11.1 or later, read them as null, and the first UPDATE of such a record erases them (no refusal at open) #12234 again. I know of no way to tell that a database holds the form short of reading every record, so the choice is between this label rule and an incomplete fence.
  • Crash between the rename and the directory fsync: the database opens under either name. Under label 2 it is already fenced; under label 1 the next read-write open relabels it again. No fixed-width array is written before the flag is set.
  • The flag: it is set from dictionary.isFixedWidthFloatArraysFenced() read after the rename attempt, so it is true only once the file carries label 2. A failed relabel leaves label 1 and the flag false, so only the varint form is written under label 1 by this build. (A database written by 26.11.x already mixes both forms under label 1; that is the state the relabel at open exists for.)
  • Hot paths: the only added cost is one volatile read in BinarySerializer.storageTypeOf, on the write of a float or double array. Nothing was added to the decode path, to Dictionary lookups or to page I/O.
  • Tests: no assertion on elapsed time (the two-minute join and the 30 s barrier are hang bounds), and no server or port is started.
  • Snapshot to a node of an older build: it refuses the dictionary and installs again once upgraded, it does not lose data. It is in the PR description for the upgrade notes; a capability gate on the sender cannot tell 26.11.x apart, since it advertises fixed-width-float-arrays and still refuses label 2.
  • Docs: the one-way door and the =false escape hatch go in the 26.12.1 upgrade notes and the settings reference with the merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Core engine: document/schema API ha High availability / replication (Raft) has-issue The PR links an issue it resolves needs-changes review-pr severity:critical Data loss, corruption, crash/hang, security hole, or product unusable storage Storage/paging/WAL engine layer triage:needs-changes PR triage: the PR needs changes before it can merge vector Vector index and embedding search

Projects

None yet

3 participants