pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: dshash: Add sequential scan support.
Date: Mon, 4 Jul 2022 13:54:04 -0700
Message-ID: <20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de> (raw)
In-Reply-To: <CA+hUKGL15uga8gxhQ1FQ1PgDwVXcwDgs1u9b1ovA+JnUUPN=+w@mail.gmail.com>
References: <E1nSTgB-000BxB-4B@gemulon.postgresql.org>
	<758107.1646960996@sss.pgh.pa.us>
	<20220311012712.botrpsikaufzteyt@alap3.anarazel.de>
	<CA+hUKGL15uga8gxhQ1FQ1PgDwVXcwDgs1u9b1ovA+JnUUPN=+w@mail.gmail.com>

Hi,

On 2022-07-04 14:55:43 +1200, Thomas Munro wrote:
> Right, as seen in the build farm at [1].  Also reproducible with something like:
>
> @@ -269,6 +269,14 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size
> request_size,
>                 return false;
>         }
>
> +       /* XXX random fault injection */
> +       if (op == DSM_OP_ATTACH && random() < RAND_MAX / 8)
> +       {
> +               close(fd);
> +               elog(ERROR, "chaos");
> +               return false;
> +       }
> +
>
> I must have thought that it was easy and practical to write no-throw
> straight-line code and be sure to reach dshash_release_lock(), but I
> concede that it was a bad idea: even dsa_get_address() can throw*, and
> you're often likely to need to call that while accessing dshash
> elements.  For example, in lookup_rowtype_tupdesc_internal(), there is
> a sequence dshash_find(), ..., dsa_get_address(), ...,
> dshash_release_lock(), and I must have considered the range of code
> between find and release to be no-throw, but now I know that it is
> not.

Yea - I'd go as far as saying that it's almost never feasible.


> > It's per-backend state at least and just used for assertions. We could remove
> > it. Or stop checking it in places where it could be set wrongly: dshash_find()
> > and dshash_detach() couldn't check anymore, but the rest of the assertions
> > would still be valid afaics?
>
> Yeah, it's all for assertions... let's just remove it.  Those
> assertions were useful to me at some stage in development but won't
> hold as well as I thought, at least without widespread PG_FINALLY(),
> which wouldn't be nice.

Hm. I'd be inclined to at least add a few more
Assert(!LWLockHeldByMe[InMode]()) style assertions. E.g. to
dshash_find_or_insert().



> @@ -572,13 +552,8 @@ dshash_release_lock(dshash_table *hash_table, void *entry)
>  	size_t		partition_index = PARTITION_FOR_HASH(item->hash);
>
>  	Assert(hash_table->control->magic == DSHASH_MAGIC);
> -	Assert(hash_table->find_locked);
> -	Assert(LWLockHeldByMeInMode(PARTITION_LOCK(hash_table, partition_index),
> -								hash_table->find_exclusively_locked
> -								? LW_EXCLUSIVE : LW_SHARED));
> +	Assert(LWLockHeldByMe(PARTITION_LOCK(hash_table, partition_index)));
>
> -	hash_table->find_locked = false;
> -	hash_table->find_exclusively_locked = false;
>  	LWLockRelease(PARTITION_LOCK(hash_table, partition_index));
>  }

This LWLockHeldByMe() doesn't add much - the LWLockRelease() will error out if
we don't hold the lock.

Greetings,

Andres Freund





view thread (11+ messages)  latest in thread

Message-ID: <20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de>
Permalink:  ../20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de/
Also on:    postgresql.org/message-id/20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, thomas.munro@gmail.com, tgl@sss.pgh.pa.us, horiguchi.kyotaro@lab.ntt.co.jp, pgsql-hackers@postgresql.org
  Subject: Re: pgsql: dshash: Add sequential scan support.
  In-Reply-To: <20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de>
  References: <E1nSTgB-000BxB-4B@gemulon.postgresql.org> <758107.1646960996@sss.pgh.pa.us> <20220311012712.botrpsikaufzteyt@alap3.anarazel.de> <CA+hUKGL15uga8gxhQ1FQ1PgDwVXcwDgs1u9b1ovA+JnUUPN=+w@mail.gmail.com> <20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox