diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-17 23:15:33 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-08-17 23:15:33 +0000 |
commit | 19cd31b0682d32142edf7599b653d4eff7031a8c (patch) | |
tree | 110b97285c4075341a357a3d9974c38ef35eed8d | |
parent | fcaad7e2c11b74c9bd30ad483b99d45a71e3f925 (diff) | |
download | postgresql-19cd31b0682d32142edf7599b653d4eff7031a8c.tar.gz postgresql-19cd31b0682d32142edf7599b653d4eff7031a8c.zip |
Fix bug introduced into _bt_getstackbuf() on 2003-Feb-21: the initial
value of 'start' could be past the end of the page, if the page was
split by some concurrent inserting process since we visited it. In
this situation the code could look at bogus entries and possibly find
a match (since after all those entries still contain what they had
before the split). This would lead to 'specified item offset is too large'
followed by 'PANIC: failed to add item to the page', as reported by Joe
Conway for scenarios involving heavy concurrent insertion activity.
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index ed08d65d99d..7cc019d8743 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.113 2004/07/21 22:31:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.114 2004/08/17 23:15:33 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1312,6 +1312,13 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access) start = minoff; /* + * Need this check too, to guard against possibility that page + * split since we visited it originally. + */ + if (start > maxoff) + start = OffsetNumberNext(maxoff); + + /* * These loops will check every item on the page --- but in an * order that's attuned to the probability of where it * actually is. Scan to the right first, then to the left. |