You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Commitdd299df, which made heap TID a tiebreaker nbtree indexcolumn, introduced new rules on page space management to make suffixtruncation safe. In general, suffix truncation needs to have a smallamount of extra space available on the new left page when splitting aleaf page. This is needed in case it turns out that truncation cannoteven "truncate away the heap TID column", resulting in alarger-than-firstright leaf high key with an explicit heap TIDrepresentation.Despite all this, CREATE INDEX/nbtsort.c did not account for thepossible need for extra heap TID space on leaf pages when decidingwhether or not a new item could fit on current page. This could lead to"failed to add item to the index page" errors when CREATEINDEX/nbtsort.c tried to finish off a leaf page that lacked space for alarger-than-firstright leaf high key (it only had space for firstrighttuple, which was just short of what was needed following "truncation").Several conditions needed to be met all at once for CREATE INDEX tofail. The problem was in the hard limit on what will fit on a page,which tends to be masked by the soft fillfactor-wise limit. The easiestway to recreate the problem seems to be a CREATE INDEX on a lowcardinality text column, with tuples that are of non-uniform width,using a fillfactor of 100.To fix, bring nbtsort.c in line with nbtsplitloc.c, which alreadypessimistically assumes that all leaf page splits will have high keysthat have a heap TID appended.Reported-By: Andreas Joseph KroghDiscussion:https://postgr.es/m/VisenaEmail.c5.3ee7fe277d514162.16a6d785bea@tc7-visena