fix(update): re-point hash indexes in batch in-place UPDATE fastPatch (stale-index bug) - #355
Merged
Merged
Conversation
…e 1) Measured root cause (probe): the B7 raw-byte fastPatch ran without write-amplification (0 file growth) but (a) re-read the length prefix per row and (b) left stale hash-index entries when the update touched an auto-indexed column - a latent data-integrity bug for EnableHashIndexes tables. - Storage.Append: buffer in-place overwrites as payload-only (no [4+len] copy/row); extracted BufferOrWriteOverwriteInPlace; added OverwriteRecordAtSameLength (skips the per-row length-prefix read when the caller guarantees same length). - IStorage/IStorageEngine: additive default methods OverwriteRecordAtSameLength / TryUpdateInPlaceSameLength (default routes to the verified path; AppendOnlyEngine uses the fast path). - Table.UpdateMultiple fastPatch: after a same-length in-place write, re-point every hash index whose column the update changed (old key from the pre-write row, new key at the same position) - fixes the stale-index bug while keeping the fast path. Validation: full SharpCoreDB.Tests suite 1635/1635 green; 222 targeted DML/fixed-width/indexing tests green; probe: UPDATE 28.3K -> 33.8K ops/s (0 file growth) and point-reads after updating an auto-indexed column return the new value (0 mismatches in 1000). Note: the same stale-index fastPatch exists on release/v2.1.0.0 and should be cherry-picked there. (cherry picked from commit 08bd7eb)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Cherry-pick of the phase-1 in-place batch-UPDATE fix (from
perf/fixedwidth-backport08bd7eb2) to the v2.1 line.Why
Measurement (probe replicating the comparative harness UPDATE workload) showed the B7 raw-byte
fastPatchinTable.UpdateMultipleran without write-amplification (0 file growth) but left stale hash-index entries whenever the update touched an auto-indexed column (EnableHashIndexes=trueindexes every column): afterUPDATE docs SET score = …, a query on the new score value returned nothing and the old value still matched. That is a data-integrity bug.What changes
Table.CRUD.csfastPatch: after a successful same-length in-place write, re-point every hash index whose column the update changed (old key decoded from the pre-write row bytes, new key added at the same position). The fast path is kept.Storage.Append.cs: buffer in-place overwrites payload-only (no[4+len]copy per row); extractedBufferOrWriteOverwriteInPlace; newOverwriteRecordAtSameLengthskips the per-row length-prefix read when the caller guarantees same length.IStorage/IStorageEngine: additive default methodsOverwriteRecordAtSameLength/TryUpdateInPlaceSameLength(default routes to the verified path;AppendOnlyEngineuses the fast path).Validation (net11)