diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-17 12:36:13 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2014-03-17 12:36:13 -0400 |
commit | c3701254b58d2323dfa399d3ed62551e2c738c48 (patch) | |
tree | 04992b067f296b794acf652a8db48fe3f66cc507 | |
parent | 3857234053fccbea6344cc4a1b632750621d51d8 (diff) | |
download | postgresql-c3701254b58d2323dfa399d3ed62551e2c738c48.tar.gz postgresql-c3701254b58d2323dfa399d3ed62551e2c738c48.zip |
During index build, check and elog (not just Assert) for broken HOT chain.
The recently-fixed bug in WAL replay could result in not finding a parent
tuple for a heap-only tuple. The existing code would either Assert or
generate an invalid index entry, neither of which is desirable. Throw a
regular error instead.
-rw-r--r-- | src/backend/catalog/index.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index d2a1eb26ac0..3dea690a1ae 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2476,7 +2476,10 @@ IndexBuildHeapScan(Relation heapRelation, rootTuple = *heapTuple; offnum = ItemPointerGetOffsetNumber(&heapTuple->t_self); - Assert(OffsetNumberIsValid(root_offsets[offnum - 1])); + if (!OffsetNumberIsValid(root_offsets[offnum - 1])) + elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"", + ItemPointerGetBlockNumber(&heapTuple->t_self), + offnum, RelationGetRelationName(heapRelation)); ItemPointerSetOffsetNumber(&rootTuple.t_self, root_offsets[offnum - 1]); @@ -2891,7 +2894,11 @@ validate_index_heapscan(Relation heapRelation, if (HeapTupleIsHeapOnly(heapTuple)) { root_offnum = root_offsets[root_offnum - 1]; - Assert(OffsetNumberIsValid(root_offnum)); + if (!OffsetNumberIsValid(root_offnum)) + elog(ERROR, "failed to find parent tuple for heap-only tuple at (%u,%u) in table \"%s\"", + ItemPointerGetBlockNumber(heapcursor), + ItemPointerGetOffsetNumber(heapcursor), + RelationGetRelationName(heapRelation)); ItemPointerSetOffsetNumber(&rootTuple, root_offnum); } |