fix(localdb): apply upserts on the primary key, not INSERT OR REPLACE (scadaproj#38)
INSERT OR REPLACE resolved a secondary UNIQUE conflict by deleting a different row (another PK) with capture suppressed and its ledger left live, so a pair diverged silently (LocalDb-003). The applier now uses INSERT ... ON CONFLICT(<pk>) DO UPDATE (DO NOTHING when every column is PK): a clash on another unique key aborts the entry, which is dead-lettered, and each node keeps its own row. Side effect: a remote update of a parent with ON DELETE RESTRICT children now applies instead of being dead-lettered. Also waits for the snapshot watermark in WipedPeer_SnapshotLiftsItsWatermark, which raced SnapshotComplete under full-suite load. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -317,7 +317,11 @@ public sealed class SnapshotResyncTests : IDisposable
|
||||
{
|
||||
var run1A = a.Session.RunAsync(d1A, cts1.Token);
|
||||
var run1B = b.Session.RunAsync(d1B, cts1.Token);
|
||||
await WaitForAsync(async () => (await ReadOrders(b.Db)).Count == 3, RunTimeout);
|
||||
// Rows land per SnapshotBatch; the watermark moves on the later SnapshotComplete. Waiting
|
||||
// on the rows alone let cts1 cancel the session between the two (an intermittent failure
|
||||
// of the assert below under full-suite load), so wait for the watermark to move at all.
|
||||
await WaitForAsync(
|
||||
async () => (await ReadOrders(b.Db)).Count == 3 && await LastAppliedRemoteSeq(b.Db) > 0, RunTimeout);
|
||||
cts1.Cancel();
|
||||
await SwallowAsync(run1A);
|
||||
await SwallowAsync(run1B);
|
||||
|
||||
Reference in New Issue
Block a user