mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +03:00
Fix locking while setting flags in MySerializableXact.
Even if a flag is modified only by the backend owning the transaction, it's not safe to modify it without a lock. Another backend might be setting or clearing a different flag in the flags field concurrently, and that operation might be lost because setting or clearing a bit in a word is not atomic. Make did-write flag a simple backend-private boolean variable, because it was only set or tested in the owning backend (except when committing a prepared transaction, but it's not worthwhile to optimize for the case of a read-only prepared transaction). This also eliminates the need to add locking where that flag is set. Also, set the did-write flag when doing DDL operations like DROP TABLE or TRUNCATE -- that was missed earlier.
This commit is contained in:
@@ -99,14 +99,13 @@ typedef struct SERIALIZABLEXACT
|
||||
*/
|
||||
#define SXACT_FLAG_CONFLICT_OUT 0x00000004
|
||||
#define SXACT_FLAG_READ_ONLY 0x00000008
|
||||
#define SXACT_FLAG_DID_WRITE 0x00000010
|
||||
#define SXACT_FLAG_MARKED_FOR_DEATH 0x00000020
|
||||
#define SXACT_FLAG_DEFERRABLE_WAITING 0x00000040
|
||||
#define SXACT_FLAG_RO_SAFE 0x00000080
|
||||
#define SXACT_FLAG_RO_UNSAFE 0x00000100
|
||||
#define SXACT_FLAG_SUMMARY_CONFLICT_IN 0x00000200
|
||||
#define SXACT_FLAG_SUMMARY_CONFLICT_OUT 0x00000400
|
||||
#define SXACT_FLAG_PREPARED 0x00000800
|
||||
#define SXACT_FLAG_MARKED_FOR_DEATH 0x00000010
|
||||
#define SXACT_FLAG_DEFERRABLE_WAITING 0x00000020
|
||||
#define SXACT_FLAG_RO_SAFE 0x00000040
|
||||
#define SXACT_FLAG_RO_UNSAFE 0x00000080
|
||||
#define SXACT_FLAG_SUMMARY_CONFLICT_IN 0x00000100
|
||||
#define SXACT_FLAG_SUMMARY_CONFLICT_OUT 0x00000200
|
||||
#define SXACT_FLAG_PREPARED 0x00000400
|
||||
|
||||
/*
|
||||
* The following types are used to provide an ad hoc list for holding
|
||||
|
||||
Reference in New Issue
Block a user