PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID15887
PG Version12beta2
Opened2019-07-03 03:04:47+00
Reported byRui Hai Jiang

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      15887
Logged by:          Rui Hai Jiang
Email address:      (redacted)
PostgreSQL version: 12beta2
Operating system:   all

In function TopoSort(), an extra "break" instruction make it impossible to
set beforeConstraints to -1 for other 
processes in the same group.  If the waiter's group has more than one
members in the wait for queue, the sorting couldn't get the right order. 

The issue exists in all V10,V11,V12 releases.

static bool
TopoSort(LOCK *lock,
                 EDGE *constraints,
                 int nConstraints,
                 PGPROC **ordering)             /* output argument */
     MemSet(beforeConstraints, 0, queue_size * sizeof(int));
        MemSet(afterConstraints, 0, queue_size * sizeof(int));
        for (i = 0; i < nConstraints; i++)
                 * Find a representative process that is on the lock queue
and part of
                 * the waiting lock group.  This may or may not be the
leader, which
                 * may or may not be waiting at all.  If there are any other
                 * in the same lock group on the queue, set their number
                 * beforeConstraints to -1 to indicate that they should be
                 * with their groupmates rather than considered
                proc = constraints[i].waiter;
                Assert(proc != NULL);
                jj = -1;
                for (j = queue_size; --j >= 0;)
                        PGPROC     *waiter = topoProcs[j];

                        if (waiter == proc || waiter->lockGroupLeader ==
                                Assert(waiter->waitLock == lock);
                                if (jj == -1)
                                        jj = j;
                                        Assert(beforeConstraints[j] <= 0);
                                        beforeConstraints[j] = -1;

A proposed patch is also sent to the hacker' list.


2019-07-03 03:04:47+00PG Bug reporting formBUG #15887: An extra "break" instruction causes a bug