Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten - Mailing list pgsql-hackers

From shihao zhong
Subject Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten
Date
Msg-id CAGRkXqQu=9iPLAnykmKa1TJcvuT0fipHpAwL+nNLEcP=PdMbug@mail.gmail.com
Whole thread
In response to Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten  (Thom Brown <thom@linux.com>)
Responses Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten
List pgsql-hackers
> + UnlockRelationOid(toastrelid, ShareUpdateExclusiveLock);
> + stop_repack_decoding_worker();
>
> Is there any opportunity for another rewrite to sneak in between these two?

Yes, but it doesn't matter. The old worker is thrown away and nothing has
been copied yet. The new worker reads the relfilenode itself when it
starts, so a rewrite before that is simply what it sees. A rewrite after
that is caught by the next check, which is made under the lock again.

The unlock has to come before starting the new worker anyway, or we are back to the deadlock.

Thanks,
Shihao

pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: aio: worker: Free SMGR objects when idle
Next
From: shihao zhong
Date:
Subject: Re: aio: worker: Free SMGR objects when idle