Re: Assertion failure while streaming toasted data

2021-05-31 Thread Amit Kapila
On Tue, May 25, 2021 at 12:51 PM Michael Paquier wrote: > > On Tue, May 25, 2021 at 12:06:38PM +0530, Pavan Deolasee wrote: > > While working on an output plugin that uses streaming protocol, I hit an > > assertion failure. Further investigations revealed a possible bug in core > > Postgres. This

Re: Assertion failure while streaming toasted data

2021-05-26 Thread Dilip Kumar
On Wed, May 26, 2021 at 5:28 PM Amit Kapila wrote: > > On Wed, May 26, 2021 at 1:47 PM Dilip Kumar wrote: > > > > On Wed, May 26, 2021 at 11:53 AM Dilip Kumar wrote: > > > > > > On Wed, May 26, 2021 at 11:19 AM Amit Kapila > > > wrote: > > > > > > > > > > > > > I searched and didn't find any s

Re: Assertion failure while streaming toasted data

2021-05-26 Thread Amit Kapila
On Wed, May 26, 2021 at 1:47 PM Dilip Kumar wrote: > > On Wed, May 26, 2021 at 11:53 AM Dilip Kumar wrote: > > > > On Wed, May 26, 2021 at 11:19 AM Amit Kapila > > wrote: > > > > > > > > > I searched and didn't find any similar existing tests. Can we think of > > > any other way to test this co

Re: Assertion failure while streaming toasted data

2021-05-26 Thread Dilip Kumar
On Wed, May 26, 2021 at 11:53 AM Dilip Kumar wrote: > > On Wed, May 26, 2021 at 11:19 AM Amit Kapila wrote: > > > > > I searched and didn't find any similar existing tests. Can we think of > > any other way to test this code path? We already have one copy test in > > toast.sql, isn't it possible

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Wed, May 26, 2021 at 11:37 AM Pavan Deolasee wrote: > > > Yeah, I wasn't very confident about this either. I just wrote it to reduce > the test footprint in the reproducer. I think we can simply include a lot > more data and do the copy via stdin. That is one way and if we don't find any be

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Wed, May 26, 2021 at 11:19 AM Amit Kapila wrote: > > On Tue, May 25, 2021 at 6:43 PM Dilip Kumar wrote: > > > > On Tue, May 25, 2021 at 5:46 PM Dilip Kumar wrote: > > > > > > On Tue, May 25, 2021 at 4:50 PM Amit Kapila > > > wrote: > > > > > > > > Your patch will fix the reported scenario b

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Wed, May 26, 2021 at 11:19 AM Amit Kapila wrote: > > > > I searched and didn't find any similar existing tests. Can we think of > any other way to test this code path? We already have one copy test in > toast.sql, isn't it possible to write a similar test here? > > Yeah, I wasn't very confiden

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Amit Kapila
On Tue, May 25, 2021 at 6:43 PM Dilip Kumar wrote: > > On Tue, May 25, 2021 at 5:46 PM Dilip Kumar wrote: > > > > On Tue, May 25, 2021 at 4:50 PM Amit Kapila wrote: > > > > > > Your patch will fix the reported scenario but I don't like the way > > > multi_insert flag is used to detect incomplete

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Tue, May 25, 2021 at 6:55 PM Dilip Kumar wrote: > On Tue, May 25, 2021 at 6:50 PM Pavan Deolasee > wrote: > > > Is that test good enough to trigger the original bug? In my experience, > I had to add a lot more tuples before the logical_decoding_work_mem > threshold was crossed and the streami

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 6:50 PM Pavan Deolasee wrote: > Is that test good enough to trigger the original bug? In my experience, I had > to add a lot more tuples before the logical_decoding_work_mem threshold was > crossed and the streaming kicked in. I would suggest running the test without >

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Tue, May 25, 2021 at 6:43 PM Dilip Kumar wrote: > > I have also added a test case for this. > > Is that test good enough to trigger the original bug? In my experience, I had to add a lot more tuples before the logical_decoding_work_mem threshold was crossed and the streaming kicked in. I would

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 5:46 PM Dilip Kumar wrote: > > On Tue, May 25, 2021 at 4:50 PM Amit Kapila wrote: > > > > Your patch will fix the reported scenario but I don't like the way > > multi_insert flag is used to detect incomplete tuple. One problem > > could be that even when there are no toast

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 4:50 PM Amit Kapila wrote: > > Your patch will fix the reported scenario but I don't like the way > multi_insert flag is used to detect incomplete tuple. One problem > could be that even when there are no toast inserts, it won't allow to > stream unless we get the last tupl

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Amit Kapila
On Tue, May 25, 2021 at 2:57 PM Dilip Kumar wrote: > > On Tue, May 25, 2021 at 2:34 PM Dilip Kumar wrote: > > > > > When the transaction is streamed, I see: > > > ``` > > > + opening a streamed block for transaction > > > + table public.toasted: INSERT: id[integer]:9001 other[text]:'bbb' > > > d

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 3:33 PM Pavan Deolasee wrote: >> The attached patch should fix the issue, now the output is like below >> > > Thanks. This looks fine to me. We should still be able to stream multi-insert > transactions (COPY) as and when the copy buffer becomes full and is flushed. > Th

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Tue, May 25, 2021 at 2:57 PM Dilip Kumar wrote: > > > > > Yes, I am able to reproduce this, basically, until we get the last > > tuple of the multi insert we can not clear the toast data otherwise we > > can never form a complete tuple. So the only possible fix I can think > > of is to consid

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 2:34 PM Dilip Kumar wrote: > > > When the transaction is streamed, I see: > > ``` > > + opening a streamed block for transaction > > + table public.toasted: INSERT: id[integer]:9001 other[text]:'bbb' > > data[text]:'ccc' > > + table public.toasted: INSERT: id[integer]:9002

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 1:59 PM Pavan Deolasee wrote: > > On Tue, May 25, 2021 at 1:49 PM Dilip Kumar wrote: >> >> On Tue, May 25, 2021 at 1:45 PM Pavan Deolasee >> wrote: >> > >> > I am not entirely sure if it works correctly. I'd tried something similar, >> > but the downstream node using >

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Tue, May 25, 2021 at 1:49 PM Dilip Kumar wrote: > On Tue, May 25, 2021 at 1:45 PM Pavan Deolasee > wrote: > > > > I am not entirely sure if it works correctly. I'd tried something > similar, but the downstream node using > > my output plugin gets NULL values for the toast columns. It's a bit

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 1:45 PM Pavan Deolasee wrote: > > I am not entirely sure if it works correctly. I'd tried something similar, > but the downstream node using > my output plugin gets NULL values for the toast columns. It's a bit hard to > demonstrate that with the > test_decoding plugin,

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Pavan Deolasee
On Tue, May 25, 2021 at 1:26 PM Dilip Kumar wrote: > > > I have identified the cause of the issue, basically, the reason is if > we are doing a multi insert operation we don't set the toast cleanup > until we get the last tuple of the xl_multi_insert [1]. Now, with > streaming, we can process th

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Dilip Kumar
On Tue, May 25, 2021 at 12:12 PM Dilip Kumar wrote: > > On Tue, May 25, 2021 at 12:06 PM Pavan Deolasee > wrote: > > > > Hi, > > > > While working on an output plugin that uses streaming protocol, I hit an > > assertion failure. Further investigations revealed a possible bug in core > > Postgre

Re: Assertion failure while streaming toasted data

2021-05-25 Thread Michael Paquier
On Tue, May 25, 2021 at 12:06:38PM +0530, Pavan Deolasee wrote: > While working on an output plugin that uses streaming protocol, I hit an > assertion failure. Further investigations revealed a possible bug in core > Postgres. This must be new to PG14 since streaming support is new to this > releas

Re: Assertion failure while streaming toasted data

2021-05-24 Thread Dilip Kumar
On Tue, May 25, 2021 at 12:06 PM Pavan Deolasee wrote: > > Hi, > > While working on an output plugin that uses streaming protocol, I hit an > assertion failure. Further investigations revealed a possible bug in core > Postgres. This must be new to PG14 since streaming support is new to this > r