[YTDB-1200, YTDB-1201, YTDB-1202] Fix link collection identity and persistence - #1313
Open
Andrii Lomakin (andrii0lomakin) wants to merge 1 commit into
Open
Andrii Lomakin (andrii0lomakin) wants to merge 1 commit into
Andrii Lomakin (andrii0lomakin) wants to merge 1 commit into
Conversation
Implemented the approved YTDB-1200, YTDB-1201, and YTDB-1202 fixes. What had to be implemented: - Correct collection identity comparison and notification behavior. - Durable negative link-collection allocation across empty bags and restart. - Domain-aware pointer validation for allocated and invalid identifiers. - Invalid-pointer rejection in both main record serializer reader variants. - Pointer round trips for link bags and link sets. - Storage format 25 with export and import required for older databases. The result preserves the existing global counter and negative allocation scheme. No high-level design changes were made. Approved high-level design: Intention: Make record identity changes and stored link collection identifiers reliable after restart. Goals: 1. Apply valid collection identifier changes and send required notifications. 2. Prevent identifier sharing within one link collection storage file. 3. Preserve that protection for empty collections and after restart. 4. Accept allocated pointers and reject invalid pointers. 5. Verify pointer serialization for link bags and link sets. 6. Reject invalid pointers when the main record serializer reads link bags and link sets. A link collection stores record references. A link bag allows duplicates. A link set rejects duplicates. A pointer identifies stored link collection data. Components: Record identity -> ChangeableRecordId -> notifications Link bags and sets -> allocator -> link storage -> recovery log -> restart counter Link bags and sets -> pointer validation -> delta and main serializers Approach: - Compare requested identity with the current collection identifier. - Notify listeners only for real identity changes. - Persist the allocation counter with pointer creation through the existing recovery mechanism. - Restore the global counter from stored link-collection state. - Accept nonnegative file identifiers with negative link-collection identifiers. - Reject invalid pointers while reading stored link bags and link sets. - Keep existing serialization formats. Non-goals: - Repairing mixed collections. - Automatic migration by scanning records. - Changing identifier signs or ownership. - Redesigning serialization formats. - Fixing YTDB-1178 concurrency behavior. - Unrelated serializer hardening. The implementation adds focused regression tests and release notes. Verification evidence remains separate from this commit message.
Andrii Lomakin (andrii0lomakin)
force-pushed
the
YTDB-1200-1201-1202-link-collection-fixes
branch
from
September 17, 2026 14:35
ca2c53c to
313e250
Compare
Andrii Lomakin (andrii0lomakin)
marked this pull request as ready for review
September 17, 2026 14:37
Test Count Gate ResultsTolerance: 5% drop allowed per module Overall: ✅ 35759 tests (baseline: 35740, +19)
|
Coverage Gate ResultsThresholds: 85% line, 70% branch Line Coverage: ✅ 90.3% (65/72 lines)
Branch Coverage: ✅ 76.9% (20/26 branches)
|
JMH LDBC Benchmark ComparisonBase: Database Load Time
Single-Thread Results
Multi-Thread Results
Gremlin Translator ResultsTranslator-on arm from
Scalability (MT/ST ratio)
|
JMH LDBC Benchmark ComparisonBase: Database Load Time
Single-Thread Results
Multi-Thread Results
Gremlin Translator ResultsTranslator-on arm from
Scalability (MT/ST ratio)
|
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.
PR Title:
[YTDB-1200, YTDB-1201, YTDB-1202] Fix link collection identity and persistence
Motivation:
This pull request fixes three related reliability problems. A link collection stores record references. A link bag allows duplicate references. A link set rejects duplicates.
A pointer identifies stored link collection data. Serialization converts database values into stored bytes. The main record serializer converts complete records to and from stored bytes. A delta serializer converts changed record fields to and from stored bytes.
ChangeableRecordIdstores a record identity that can change.LinkBagPointeridentifies a link collection location.Record identity updates can compare against the wrong field. Empty live link collections can lose allocation evidence after restart. Allocator-produced pointers can be rejected as invalid. These defects can skip notifications, reuse identifiers, and bypass pointer serialization. The design keeps the existing identifier model and protects stored references.
Planned changes:
Intention
Make record identity changes and stored link collection identifiers reliable, including after restart.
Goals
Components and data flow
A recovery log records storage changes for failure recovery. It writes counter state with pointer creation, so restart can restore the counter from storage.
Current state
ChangeableRecordIdcan compare a requested collection identifier with a record position. Empty live link collections can lose allocation evidence after restart.LinkBagPointerrejects negative identifiers produced by the allocator. The main record serializer does not reject every invalid stored pointer.What changes
Identity changes compare the requested identifier with the current identifier. Real changes send before and after notifications. No-op assignments send no notifications.
The allocator keeps negative identifiers and the existing database-wide counter. Counter information persists with link collection storage through the existing recovery mechanism. Counter and pointer updates commit together. Restart allocation continues beyond every committed identifier, including identifiers for empty collections.
Pointer validation accepts a nonnegative file identifier with a negative link collection identifier. Pointer validation rejects invalid file identifiers and invalid zero or positive link collection identifiers. Both serializers apply this validation while reading link bags and link sets.
Approach
Use the existing recovery mechanism for counter updates. Validate pointers across both serializer paths. Test valid negative identifiers, invalid file identifiers, and invalid zero or positive link collection identifiers. Test round trips for both link bags and link sets.
Key decisions
Out of scope
Risks & accepted trade-offs
Suggestions:
None.
Verification approach
Verify identity changes and notifications. Verify pointer validity and round trips for bags and sets. Verify empty-collection restart allocation, rollback, and crash recovery. Run relevant unit and integration tests. Measure changed-line coverage under the project gate.
The compile gate passed. The core suite passed with 1,930 tests, zero failures, zero errors, and 20 skips. Selected integration tests passed with seven tests and no failures. Coverage passed with 90.3 percent line coverage and 76.9 percent branch coverage across 21 changed Java files.