mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix a couple of snapshot management bugs in the new ResourceOwner world:
non-writable large objects need to have their snapshots registered on the transaction resowner, not the current portal's, because it must persist until the large object is closed (which the portal does not). Also, ensure that the serializable snapshot is recorded by the transaction resource owner too, even when a subtransaction has changed the current resource owner before serializable is taken. Per bug reports from Pavan Deolasee.
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.135 2008/11/02 01:45:28 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.136 2008/12/04 14:51:02 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -247,7 +247,13 @@ inv_open(Oid lobjId, int flags, MemoryContext mcxt)
|
||||
}
|
||||
else if (flags & INV_READ)
|
||||
{
|
||||
retval->snapshot = RegisterSnapshot(GetActiveSnapshot());
|
||||
/*
|
||||
* We must register the snapshot in TopTransaction's resowner,
|
||||
* because it must stay alive until the LO is closed rather than until
|
||||
* the current portal shuts down.
|
||||
*/
|
||||
retval->snapshot = RegisterSnapshotOnOwner(GetActiveSnapshot(),
|
||||
TopTransactionResourceOwner);
|
||||
retval->flags = IFS_RDLOCK;
|
||||
}
|
||||
else
|
||||
@ -270,8 +276,11 @@ void
|
||||
inv_close(LargeObjectDesc *obj_desc)
|
||||
{
|
||||
Assert(PointerIsValid(obj_desc));
|
||||
|
||||
if (obj_desc->snapshot != SnapshotNow)
|
||||
UnregisterSnapshot(obj_desc->snapshot);
|
||||
UnregisterSnapshotFromOwner(obj_desc->snapshot,
|
||||
TopTransactionResourceOwner);
|
||||
|
||||
pfree(obj_desc);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user