Re: Throwing away unnecessary spin-locks - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Throwing away unnecessary spin-locks
Date
Msg-id yvmmtoinl655fpdbravy6kqti4d3yeqaclhywqzqm4xsklmnlz@qejqsnhxipa4
Whole thread
In response to Re: Throwing away unnecessary spin-locks  (Alexandre Felipe <o.alexandre.felipe@gmail.com>)
Responses Re: Throwing away unnecessary spin-locks
List pgsql-hackers
Hi,

I'm sorry to be blunt, but this dangerous stuff.  You're just doing mechanical
replacements, without any analysis. That's a recipe for hard to encounter and
find bugs.

It also doesn't make any sort of sense to me to use slock_* or whatnot. This
has nothing to do with spinlocks.


> @@ -2748,9 +2746,7 @@ XLogSetAsyncXactLSN(XLogRecPtr asyncXactLSN)
>  void
>  XLogSetReplicationSlotMinimumLSN(XLogRecPtr lsn)
>  {
> -    SpinLockAcquire(&XLogCtl->info_lck);
> -    XLogCtl->replicationSlotMinLSN = lsn;
> -    SpinLockRelease(&XLogCtl->info_lck);
> +    slock_write_uint64(&XLogCtl->info_lck, &XLogCtl->replicationSlotMinLSN, lsn);
>  }

Just about all the write side ones are completely wrong.  This allows the
field to be set while someone else holds the spinlock.  As I said before, this
needs careful, documented, analysis FOR EACH AND EVERY SINGLE CHANGE.

This isn't to say that the read sides are right either. Some of them very well
might depend on the read not happening while multiple fields were updated with
the lock held.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Alexandre Felipe
Date:
Subject: Re: Throwing away unnecessary spin-locks
Next
From: Manu
Date:
Subject: Re: BUG #19686: Rolling back SET TABLESPACE