Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key

From: amul sul <sulamul(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Restrict concurrent update/delete with UPDATE of partition key
Date: 2018-02-07 12:43:51
Message-ID: CAAJ_b94rtTW+J-_NH0V_q13SXLyMt0d1NSj+SAh439j3c-wPmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 6, 2018 at 7:05 PM, amul sul <sulamul(at)gmail(dot)com> wrote:
> On Sun, Feb 4, 2018 at 10:47 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> On Fri, Feb 2, 2018 at 2:11 PM, amul sul <sulamul(at)gmail(dot)com> wrote:
>>> On Fri, Jan 26, 2018 at 11:58 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
[....]
>>
>> I wonder what will be the behavior of this patch with
>> wal_consistency_checking [1]. I think it will generate a failure as
>> there is nothing in WAL to replay it. Can you once try it? If we see
>> a failure with wal consistency checker, then we need to think whether
>> (a) we want to deal with it by logging this information, or (b) do we
>> want to mask it or (c) something else?
>>
>>
>> [1] - https://www.postgresql.org/docs/devel/static/runtime-config-developer.html
>>
>
> Yes, you are correct standby stopped with a following error:
>
> FATAL: inconsistent page found, rel 1663/13260/16390, forknum 0, blkno 0
> CONTEXT: WAL redo at 0/3002510 for Heap/DELETE: off 6 KEYS_UPDATED
> LOG: startup process (PID 22791) exited with exit code 1
> LOG: terminating any other active server processes
> LOG: database system is shut down
>
> I have tested warm standby replication setup using attached script. Without
> wal_consistency_checking setting, it works fine & data from master to standby is
> replicated as expected, if this guaranty is enough then I think could skip this
> error from wal consistent check for such deleted tuple (I guess option
> b that you have suggested), thoughts?

I tried to mask ctid.ip_blkid if it is set to InvalidBlockId with
following change in heap_mask:

------------- PATCH -------------
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 682f4f07a8..e7c011f9a5 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -9323,6 +9323,10 @@ heap_mask(char *pagedata, BlockNumber blkno)
*/
if (HeapTupleHeaderIsSpeculative(page_htup))
ItemPointerSet(&page_htup->t_ctid, blkno, off);
+
+ /* TODO : comments ? */
+ if (!BlockNumberIsValid(BlockIdGetBlockNumber((&((page_htup->t_ctid).ip_blkid)))))
+ BlockIdSet(&((page_htup->t_ctid).ip_blkid), blkno);
}

/*
------------- END -------------

Test script[1] works as expected with this change but I don't have much
confident on it due to lack of knowledge of wal_consistency_checking
routine. Any suggestion/comments will be much appreciated, thanks!

[1] https://postgr.es/m/CAAJ_b94_29wiUA83W8LQjtfjv9XNV=+PT8+ioWRPjnnFHe3eqw@mail.gmail.com

Regards,
Amul

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-02-07 13:19:44 Re: [HACKERS] path toward faster partition pruning
Previous Message Amit Kapila 2018-02-07 12:30:01 Re: In logical replication concurrent update of partition key creates a duplicate record on standby.