https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119151
--- Comment #12 from Michael Leuchtenburg <michael at slashhome dot org> --- It looks like the failures I was continuing to see in our use-case were indeed a test configuration issue as they are now passing, using my old patch. The new change is functionally the same, it just does one fewer search through children for splits. I also wrote a little unit stress test which hasn't found anything. It spins up 10 threads and has them each insert and remove parts of a range, continuously, with some random delays to try to mix up the timing. It's set up so that there should be blocks inserted which overlap the endpoint of a previously inserted block, which is the case where the old code failed. It's passing for me. I think that if we were merging different types of node we would have a lot of other sorts of crash. B-trees in general should have all the same node type at a given level. But I am in favor of adding more asserts to this code in general as it should make it a little easier to understand and will help protect against bugs. I'm very curious as to why it worked for Thomas Neumann's use-case before since AFAIK it's the same as ours - a database which is compiling plans and loading them. A different memory allocation strategy could make it not happen, as if you never deregister an object and re-use the memory for a new object in a slightly different position (specifically with a higher end-point) you won't trigger the bug. Same if you never deregister, though that only seems viable for ephemeral processes. The changes in master look like they should backport cleanly onto 14.2.0 so I'll try the patch there.