pgsql: Improve error detection capability in proclists.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve error detection capability in proclists.
Date: 2018-01-08 23:28:13
Message-ID: E1eYgpx-0001BP-C7@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve error detection capability in proclists.

Previously, although the initial state of a proclist_node is expected
to be next == prev == 0, proclist_delete_offset would reset nodes to
next == prev == INVALID_PGPROCNO when removing them from a list.
This is the same state that a node in a singleton list has, so that
it's impossible to distinguish not-in-a-list from in-a-list. Change
proclist_delete_offset to reset removed nodes to next == prev == 0,
making it possible to distinguish those cases, and then add Asserts
to the list add and delete functions that the supplied node isn't
or is in a list at entry. Also tighten assertions about the node
being in the particular list (not some other one) where it is possible
to check that in O(1) time.

In ConditionVariablePrepareToSleep, since we don't expect the process's
cvWaitLink to already be in a list, remove the more-or-less-useless
proclist_contains check; we'd rather have proclist_push_tail's new
assertion fire if that happens.

Improve various comments related to proclists, too.

Patch by me, reviewed by Thomas Munro. This isn't back-patchable, since
there could theoretically be inlined copies of proclist_delete_offset in
third-party modules. But it's only improving debuggability anyway.

Discussion: https://postgr.es/m/CAEepm=0NWKehYw7NDoUSf8juuKOPRnCyY3vuaSvhrEWsOTAa3w@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ea8e1bbc538444d373cf712a0f5188c906b71a9d

Modified Files
--------------
src/backend/storage/lmgr/condition_variable.c | 3 +-
src/include/storage/proclist.h | 55 ++++++++++++++++-----------
src/include/storage/proclist_types.h | 12 ++++--
3 files changed, 43 insertions(+), 27 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2018-01-09 03:44:01 pgsql: pg_upgrade: prevent check on live cluster from generating error
Previous Message Andrew Dunstan 2018-01-08 17:02:52 Re: Buildfarm status monitoring (was Re: pgsql: Implement channel binding tls-server-end-point for SCRAM)