Re: Temporary tables prevent autovacuum, leading to XID wraparound - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Temporary tables prevent autovacuum, leading to XID wraparound
Date
Msg-id 20180813095616.rd7asbxvf2doyva5@alap3.anarazel.de
Whole thread Raw
In response to Re: Temporary tables prevent autovacuum, leading to XID wraparound  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Temporary tables prevent autovacuum, leading to XID wraparound
List pgsql-hackers
On 2018-08-09 18:50:47 +0200, Michael Paquier wrote:
> On Thu, Aug 09, 2018 at 02:29:54AM -0700, Andres Freund wrote:
> +   /*
> +    * 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,
> +    * there is no visible temporary relations associated to it and the
> +    * temporary namespace creation is not committed yet, so none of its
> +    * contents should be seen yet if scanning pg_class or pg_namespace.
> +    */

> I actually have tried to mention what you are willing to see in the
> comments with the last sentence.  So that is awkward :)

I don't know what you're trying to say with this.

> I would propose to reword the last sentence of the patch as follows
> then:
> "Even if it is not atomic, 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."
> 
> When resetting the value on abort I have that:
> +   /*
> +    * Reset the temporary namespace flag in MyProc. The creation of
> +    * the temporary namespace has failed for some reason and should
> +    * not be seen by other processes as it has not been committed
> +    * yet, hence this would be fine even if not atomic, still we
> +    * assume that it is an atomic assignment.
> +    */
> 
> Hence I would propose the following wording for this part:
> "Reset the temporary namespace flag in MyProc.  We assume that this
> operation is atomic, however it would be fine even if not atomic as the
> temporary table which created this namespace is still locked until this
> transaction aborts so it would not be visible yet."

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.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Temporary tables prevent autovacuum, leading to XID wraparound
Next
From: Heikki Linnakangas
Date:
Subject: Re: [HACKERS] possible self-deadlock window after badProcessStartupPacket