On Mon, Aug 13, 2018 at 02:56:16AM -0700, Andres Freund wrote: > On 2018-08-09 18:50:47 +0200, Michael Paquier wrote: > I don't think that comment, nor the comment that you ended up > committing: > + > + /* > + * Reset the temporary namespace flag in MyProc. We assume that > + * this operation is atomic. Even if it is not, the temporary > + * table which created this namespace is still locked until this > + * transaction aborts so it would not be visible yet, acting as a > + * barrier. > + */ > > is actually correct. *Holding* a lock isn't a memory barrier. Acquring > or releasing one is.
I cannot guess what you think, but would something like the attached be more adapted? Both things look rather similar to me now, likely for you it does not. -- Michael
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 3971346e73..f0f692fe09 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -3937,9 +3937,11 @@ InitTempTableNamespace(void) * Mark MyProc as owning this namespace which other processes can use to * decide if a temporary namespace is in use or not. We assume that * assignment of namespaceId is an atomic operation. Even if it is not, - * the temporary relation which resulted in the creation of this temporary - * namespace is still locked until the current transaction commits, so it - * would not be accessible yet, acting as a barrier. + * the lock acquired on the temporary relation which created this + * namespace serves as a memory barrier which guarantees a value of + * tempNamespaceId recent enough. All the contents of this namespace will + * become visible once the current transaction commits, releasing the lock + * previously acquired. */ MyProc->tempNamespaceId = namespaceId; @@ -3976,10 +3978,12 @@ AtEOXact_Namespace(bool isCommit, bool parallel) /* * Reset the temporary namespace flag in MyProc. We assume that - * this operation is atomic. Even if it is not, the temporary - * table which created this namespace is still locked until this - * transaction aborts so it would not be visible yet, acting as a - * barrier. + * this operation is atomic. Even if it is not, the lock acquired + * on the temporary table which created this namespace serves as a + * memory barrier which guarantees a value of tempNamespaceId + * recent enough. Nothing from this temporary namespace will be + * visible as this transaction aborts, releasing also the + * previously-acquired lock. */ MyProc->tempNamespaceId = InvalidOid; } @@ -4037,10 +4041,12 @@ AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, /* * Reset the temporary namespace flag in MyProc. We assume that - * this operation is atomic. Even if it is not, the temporary - * table which created this namespace is still locked until this - * transaction aborts so it would not be visible yet, acting as a - * barrier. + * this operation is atomic. Even if it is not, the lock acquired + * on the temporary table which created this namespace serves as a + * memory barrier which guarantees a value of tempNamespaceId + * recent enough. Nothing from this temporary namespace will be + * visible as this transaction aborts, releasing also the + * previously-acquired lock. */ MyProc->tempNamespaceId = InvalidOid; }
signature.asc
Description: PGP signature