Repository navigation
Fix sorting of records when processing batches. - #571
Merged
Merged
Conversation
mbrandonw
commented
Nov 3, 2026
Comment on lines
-1094
to
-1097
| let lhsRecordType = lhs.tableName, | ||
| let lhsIndex = tablesByOrder[lhsRecordType], | ||
| let rhsRecordType = rhs.tableName, | ||
| let rhsIndex = tablesByOrder[rhsRecordType] |
Member
Author
There was a problem hiding this comment.
For tables that have no references, these values would be nil, and we would fallback to returning true below, which ultimately can cause any value to be shifted around while sorting. We already have a helper for properly comparing tablesByOrder values, which is topologicallyAscending, and it further sorts tables with no references alphabetically after all tables with references.
mario-luis-dev
added a commit
to mario-luis-dev/sqlite-data
that referenced
this pull request
Nov 9, 2026
Brings in what upstream merged after 1.12.1, unreleased: the upload sort (pointfreeco#571), quotaExceeded saves parked and sent again (pointfreeco#335, pointfreeco#576), cached records waiting for their parent (pointfreeco#567), CloudKit rate limiting (pointfreeco#569, pointfreeco#564), the mock database's modification dates (pointfreeco#574) and the @fetch load race (pointfreeco#536). Conflicts, resolved: - Upload sort: upstream's topologicallyAscending replaces the fork's own comparator; the fork's reference violation guard stays. - enqueueLocallyPendingChanges takes upstream's scope, and still reads, queues and removes the queued notes in one write, so a note written while sync starts is queued exactly once. Notes written while sync is stopped record their database, as upstream's do. - MockSyncEngineState takes upstream's single State, and keeps the fork's hook before adding changes and its rule that only the last save or deletion of a record stays queued. - MockCloudDatabase takes upstream's records(for:) and keeps the fork's recordsLookupError and deletionLog. The fork's own server lookups (settleDependents, the lost deletion and leftover record checks) go through upstream's batched records(for:), so they wait and try again when CloudKit limits the request rate. Tests: MyDelegate is upstream's AccountChangedDelegate now; a share's snapshot shows cloudkit.title as in upstream's; PreviewTests.delete() waits for the preview timer's send to return before it ends (the fork's sends do more after the server changes, and the test ended while one was still returning in 4 of 5 full runs). Full suite: 421 pass, 6 runs in a row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yusuferisen
pushed a commit
to Mango-Grove-Labs/sqlite-data
that referenced
this pull request
Nov 25, 2026
…atabase, upstream pointfreeco#571, the schema backfill skips deleted rows MonteSprout Phase 120.6 (second bug bash, A-F6–A-F8 — upstream behaviour, found by reading). (a) A-F6: handleFetchedRecordZoneChanges' retry drain asked syncEngine.database (the database of whichever engine handled the event) for every parked UnsyncedRecordID, though the park table holds both scopes. A shared-zone ID asked of the private database could answer .unknownItem on hardware (same zone name, different owner), which deletes the park for good. The drain now groups the sorted IDs by zone owner (owned first, topological order kept per group) and fetches each group from container.database(for:) — patch 11's router. RetryDrainDatabaseTests (2): an event of either scope applies a parked record of the other. (b) A-F7, half: upstream pointfreeco#571 (43de040) taken — source and its test CloudKitTests.sendParentsBeforeChildren, not its Package.resolved. The batch comparator is now a strict weak ordering (topologicallyAscending, default: false). Upstream pointfreeco#418 deliberately not taken; it waits for the next retarget, as does pointfreeco#574. (c) A-F8: updateLocalFromSchemaChange's archive read skips _isDeleted rows, so the backfill no longer re-creates a row whose delete is queued (an untracked ghost once the delete is sent). SchemaChangeTests.backfillSkipsARowWhoseDeleteIsQueued. All three guards verified red by neutralizing in place. Full suite 422 pass, 21 known issues unchanged; no snapshot re-recorded. MANGO-PATCHES § 25; PROGRESS 14.5 ticked — Phase 14 complete; JOURNAL entry. No pin moves: the consumer pin moves in MonteSprout 120.7. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
#568 brought up that there was a problem with sorting records when sending off batches, and this is an a simpler approach to that problem. Test taken from that PR.