Repository navigation
fix: metadata only serialized on schema change (#532) + document at-rest encryption default (#531) - #533
Open
MPCoreDeveloper wants to merge 2 commits into
Open
fix: metadata only serialized on schema change (#532) + document at-rest encryption default (#531)#533MPCoreDeveloper wants to merge 2 commits into
MPCoreDeveloper wants to merge 2 commits into
Conversation
Database.Flush() called SaveMetadata() unconditionally, so any caller that flushed per operation (a durable queue write, a log append, a move or a delete) paid a full TableMetadataDto build + JSON serialization + meta.dat rewrite on every row -- measured ~1.45 ms/op on NTFS and ~24.8 ms/op on ReFS. Introduce a dedicated schema-dirty signal (_schemaDirty), separate from the existing data-dirty flag (_metadataDirty, set by INSERT/UPDATE/DELETE for SELECT visibility), and call SaveMetadata() from Flush() only when the schema actually changed. The DDL path already persists the schema eagerly through ForceSave() (and the batch dispatcher / Dispose save it directly), so a data-only flush now skips the metadata work while the data flush (WAL batch buffer, tables, storage provider, storage engine) and its durability are unchanged. Also document the 2.2.0 EnableAtRestRecordEncryption default flip (false in 2.0.0.x, true in 2.2.0; ~40% point-read cost; EnableBatchEncryption is a different layer) on the property and in the changelog, and pin the secure default with DatabaseConfigDefaultsTests so an accidental flip back fails the build (#531). Tests: - DatabaseFlushMetadataTests (4 cases) -- 2 failed before (MetadataSaveCount 1->2 on one flush, 1->21 over 20 flushes) and pass after. - DatabaseConfigDefaultsTests (2 cases). Wider core suite: 3091 tests / 0 failed / 22 skipped; canaries + new tests 63/63. Build: 0 errors. Refs #532, #531. #532 closes only after the reporter's ServiceMq harness is re-run against the fixed build (see .clinerules/30-issue-closure.md).
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
The comparative harness flushes once per batch/phase, so it never exercises the per-row IDatabase.Flush() pattern issue #532 is about. Add a focused --flush-per-row mode: N single-row ITable.Insert writes, each followed by either IDatabase.Flush() or ITable.Flush(), interleaved and reported as a median on the same table and machine. Measured (AppendOnly, at-rest records on, 5,000 rows/arm, 2 reps): before the fix: IDatabase.Flush 3,109 ops/s vs ITable.Flush 5,063 ops/s (1.63x gap) after the fix: IDatabase.Flush 5,301 ops/s vs ITable.Flush 5,281 ops/s (1.00x gap) Refs #532.
This was referenced Nov 29, 2026
|
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
Fixes the metadata-flush cost in issue #532 and documents the at-rest-encryption default flip in issue #531, with regression tests for both. Issue #171 is dispositioned as out of scope for this repository.
#532 —
Database.Flush()no longer re-serializes every table's metadata on a data-only flushDatabase.Flush()calledSaveMetadata()unconditionally, so any caller that flushed per operation (a durable queue write, a log append, a move or a delete) paid a fullTableMetadataDtobuild + JSON serialization +meta.datrewrite on every row — ~1.45 ms/op on NTFS and ~24.8 ms/op on ReFS per the reporter.Key finding: the issue's suggested fix ("consult
_metadataDirty") is insufficient, because_metadataDirtyis also set by INSERT/UPDATE/DELETE — it tracks pending data for SELECT visibility, not schema. The fix introduces a dedicated_schemaDirtysignal and gatesSaveMetadata()inFlush()on it. The DDL path already persists the schema eagerly throughForceSave()(the batch dispatcher andDisposesave it directly), so a data-only flush now skips the metadata work while the data flush (WAL batch buffer, tables, storage provider, storage engine) and its durability are unchanged.Files:
Database.Core.cs(_schemaDirty,MetadataSaveCount,Flush()gate,SaveMetadata()clear),Database.Execution.cs(4 DDL branches),Database.Batch.cs(batch schema branch).#531 — documented the 2.2.0
EnableAtRestRecordEncryptiondefault flipfalse(2.0.0.x) →true(2.2.0) flip, the ~40% (~1.66×) point-read cost, and theEnableBatchEncryptioninteraction (a different layer).docs/CHANGELOG.md: 2.2.0 Changed entry for the flip.DatabaseConfigDefaultsTestspins the secure default so an accidental flip-back fails the build.true(constitution Principle I); flipping it is an owner decision.#171 — out of scope
The graphical UI belongs to
MPCoreDeveloper/SCDMS(constitution Principle V). No code; dispositioned in the spec.Tests
DatabaseFlushMetadataTests(4 cases) — 2 failed before (MetadataSaveCount1→2 on one flush, 1→21 over 20 flushes), 4 pass after.DatabaseConfigDefaultsTests(2 cases) — pass.Category!=Debug/Manual/Performance): 3091 tests / 0 failed / 22 skipped.Spec-kit
specs/001-metadata-flush-cost/{spec,plan,tasks}.md.Issue closure
#532 closes only after the reporter's own ServiceMq harness is re-run against a fixed build (
.clinerules/30-issue-closure.md); the fix is on this branch, not yet released. #531's documentation asks are answered; its ask 3 (workload-dependent default) is an explicit owner decision. Merging intomasteris an owner action.