On Thu, 11 Mar 2021 at 16:16, John Naylor <john.nay...@enterprisedb.com> wrote: > > On Thu, Mar 11, 2021 at 9:46 AM Matthias van de Meent > <boekewurm+postg...@gmail.com> wrote: > > > Regarding the 2% slack logic, could we change it to use increments of > > line pointers instead? That makes it more clear what problem this > > solution is trying to work around; that is to say line pointers not > > (all) being truncated away. The currently subtracted value accounts > > That makes sense. > > > ... > > - if (len + saveFreeSpace > MaxHeapTupleSize) > > + if (len + saveFreeSpace > maxPaddedFsmRequest) > > ... > > - targetFreeSpace = Max(len, MaxHeapTupleSize - (MaxHeapTupleSize * 2 / > > 100)); > > + targetFreeSpace = Max(len, maxPaddedFsmRequest); > > ... > > If we have that convenient constant, it seems equivalent (I think) and a bit > more clear to write it this way, but I'm not wedded to it: > > if (len + saveFreeSpace > MaxHeapTupleSize && > len <= maxPaddedFsmRequest) > { > ... > targetFreeSpace = maxPaddedFsmRequest; > }
+ else if (len > maxPaddedFsmRequest + { + /* request len amount of space; it might still fit on not-quite-empty pages */ + targetFreeSpace = len; + } If this case isn't added, the lower else branch will fail to find fitting pages for len > maxPaddedFsmRequest tuples; potentially extending the relation when there is actually still enough space available. > else > targetFreeSpace = len + saveFreeSpace; > Also, should I write a regression test for it? The test case is already > available, just no obvious place to put it. I think it would be difficult to write tests that exhibit the correct behaviour on BLCKSZ != 8196. On the other hand, I see there are some tests that explicitly call out that they expect BLCKSZ to be 8192, so that has not really been a hard block before. The previous code I sent had initial INSERT + DELETE + VACUUM. These statements can be replaced with `INSERT INTO t_failure (b) VALUES (repeat('1', 95)); VACUUM;` for simplicity. The vacuum is still needed to populate the FSM for the new page. With regards, Matthias van de Meent