Repository navigation
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
Conversation
…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.
|
Warning Review limit reachedYou'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. View limit details
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. |
|
This pull request is merged. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
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.
|
Triage: SummaryThe approach is sound. It reuses the existing Requested changes
|
|
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.
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]>
|
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). Second finding from the same review.
Tests run on 743c5f2:
|
|
Triage: 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.
2. A live rename of a component file is the riskiest part.
3. Decoding a value now has a side effect.
4. Minor points.
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. |
…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.
|
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 What changed, and why The label was applied lazily, on the first fixed-width array serialized and on the first one decoded through
Now the label follows the setting. While Also in the commit:
On the review points
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.
|
|
Triage: Review of #12239The fence idea is sound. It reuses the existing Blocking: the diff does not do what the description saysThe 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:
Please decide which behaviour is intended, then make the code, tests, Javadoc and PR body agree.
Also, Other points
|
…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.
|
Triage: 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 Blocking: the default makes the upgrade a one-way door.
Risk areas that need a maintainer's careful review:
Conventions:
|
|
On the review of e6a1b05:
|
What does this PR do?
Fixes #12234.
Since 26.11.1,
ARRAY_OF_FLOATS/ARRAY_OF_DOUBLESvalues (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 asnull, leave the records out ofvector.neighbors(), and the firstUPDATEof 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:
(
Dictionaryload 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.arcadedb.serializer.fixedWidthFloatArrays(defaulttrue), 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.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./api/v1/cluster/checksums(SnapshotManager.computeFileChecksums), the verify handler (PostVerifyDatabaseHandler) andBootstrapFingerprintreport 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 readisOpen()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).arcadedb.serializer.fixedWidthFloatArrays=falsebefore the first read-write open by this build (or a backup taken before the upgrade).dictionary.<id>.<pageSize>.v2.dictback 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.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:emb=null;UPDATEof row 4 erases its arraysDatabaseMetadataException: Dictionary '.../dictionary.0.65536.v2.dict' was written with format version 2, which this version of ArcadeDB cannot read (latest known is 1)CHECK DATABASE0 errors(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.mvn -o -pl engine -am test -DexcludedGroups=benchmark,slow,vector: 27,711 tests, 4 not passing, all inCypherCallInTransactionsOnErrorIssue11595Test(3 errors) andParallelSafeExpressionsStateTest(1 failure), which fail the same way on main.