Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2999ab

Browse files
committed
Fix assertion failure in logical decoding.
Logical decoding set SnapshotData's regd_count field to avoid thesnapshot manager from prematurely freeing snapshots that are generatedby the decoding system. That was always an abuse of the field, as it wasnever supposed to be used outside the snapshot manager. Commit9402869made snapshot manager's tracking of the snapshots smarter, and that schemefell apart. The snapshot manager got confused and hit the assertion, whena snapshot that was marked with regd_count==1 was not found in the heap,where the snapshot manager tracks registered the snapshots.To fix, don't abuse the regd_count field like that. Logical decoding stillabuses the active_count field for similar purposes, but that's currentlyharmless.The assertion failure was first reported by Michael Paquier
1 parent90898af commite2999ab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,8 +1188,8 @@ ReorderBufferCopySnap(ReorderBuffer *rb, Snapshot orig_snap,
11881188
memcpy(snap,orig_snap,sizeof(SnapshotData));
11891189

11901190
snap->copied= true;
1191-
snap->active_count=0;
1192-
snap->regd_count=1;
1191+
snap->active_count=1;/* mark as active so nobody frees it */
1192+
snap->regd_count=0;
11931193
snap->xip= (TransactionId*) (snap+1);
11941194

11951195
memcpy(snap->xip,orig_snap->xip,sizeof(TransactionId)*snap->xcnt);

‎src/backend/replication/logical/snapbuild.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ SnapBuildFreeSnapshot(Snapshot snap)
348348
Assert(snap->curcid==FirstCommandId);
349349
Assert(!snap->suboverflowed);
350350
Assert(!snap->takenDuringRecovery);
351-
Assert(snap->regd_count==1);
351+
Assert(snap->regd_count==0);
352352

353353
/* slightly more likely, so it's checked even without c-asserts */
354354
if (snap->copied)
@@ -407,16 +407,16 @@ SnapBuildSnapDecRefcount(Snapshot snap)
407407
Assert(!snap->suboverflowed);
408408
Assert(!snap->takenDuringRecovery);
409409

410-
Assert(snap->regd_count==1);
410+
Assert(snap->regd_count==0);
411411

412-
Assert(snap->active_count);
412+
Assert(snap->active_count>0);
413413

414414
/* slightly more likely, so it's checked even without casserts */
415415
if (snap->copied)
416416
elog(ERROR,"cannot free a copied snapshot");
417417

418418
snap->active_count--;
419-
if (!snap->active_count)
419+
if (snap->active_count==0)
420420
SnapBuildFreeSnapshot(snap);
421421
}
422422

@@ -495,7 +495,7 @@ SnapBuildBuildSnapshot(SnapBuild *builder, TransactionId xid)
495495
snapshot->copied= false;
496496
snapshot->curcid=FirstCommandId;
497497
snapshot->active_count=0;
498-
snapshot->regd_count=1;/* mark as registered so nobody frees it */
498+
snapshot->regd_count=0;
499499

500500
returnsnapshot;
501501
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp