Re: VACUUM FULL results in deadlock

From: Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: VACUUM FULL results in deadlock
Date: 2019-07-04 13:11:49
Message-ID: CA+u7OA7nY-AL1G8L8brsS=7jmRmmRp2kt05=XR3MDwPXVPvzHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi everyone,

Did anyone try to verify this? I found a number of other race
conditions where VACUUM causes errors such as "ERROR: found unexpected
null value in index "i0", "invalid input syntax for type boolean", or
"missing chunk number 0 for toast value 13171 in pg_toast_2619".
Fixing this would help me to narrow down these issues.

Best,
Manuel

On Sat, Jun 29, 2019 at 5:51 PM Manuel Rigger <rigger(dot)manuel(at)gmail(dot)com> wrote:
>
> Hi everyone,
>
> When executing multiple threads that execute VACUUM FULL on distinct
> databases, a deadlock like the following can occur:
>
> ERROR: deadlock detected
> Detail: Process 16407 waits for AccessShareLock on relation 1260 of
> database 0; blocked by process 16404.
> Process 16404 waits for RowExclusiveLock on relation 1214 of database
> 0; blocked by process 16407.
> Hint: See server log for query details.
>
> This is unexpected, because the documentation does not mention that
> VACUUM FULL can result in a deadlock. Also, VACUUM without a table
> argument should affect only the current database [1]:
>
> "Without a table_and_columns list, VACUUM processes every table and
> materialized view in the current database that the current user has
> permission to vacuum."
>
> To reproduce such a deadlock, I've attached a Java program that first
> creates 32 databases (test0 to test31), and then starts 32 threads,
> each one connecting to one of the databases (with superuser
> privileges). Every thread then repeatedly executes "VACUUM FULL".
> Within a few seconds, deadlock error messages should pop up.
>
> I'm using the following Postgres version: psql (11.4 (Ubuntu
> 11.4-1.pgdg19.04+1)).
>
> Is this a bug?
>
> Best,
> Manuel
>
> [1] https://www.postgresql.org/docs/11/sql-vacuum.html

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message James Inform 2019-07-04 13:41:45 Re: BUG #15892: URGENT: Using an ICU collation in a primary key column breaks ILIKE query
Previous Message Manuel Rigger 2019-07-04 13:06:52 Re: SELECT results in "ERROR: index key does not match expected index column"