8000 Revert "DEBUG: Index scan and page split instrumentation" · petergeoghegan/postgres@2eec9b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2eec9b5

Browse files
Revert "DEBUG: Index scan and page split instrumentation"
This reverts commit 6a3fbcc878313313c6e391cd90a79e0a319f36de.
1 parent 0f1d215 commit 2eec9b5

File tree

19 files changed

+65
-1540
lines changed

19 files changed

+65
-1540
lines changed

contrib/amcheck/verify_nbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,7 @@ bt_rootdescend(BtreeCheckState *state, IndexTuple itup)
30403040
*/
30413041
Assert(state->readonly && state->rootdescend);
30423042
exists = false;
3043-
stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ, NULL);
3043+
stack = _bt_search(state->rel, NULL, key, &lbuf, BT_READ);
30443044

30453045
if (BufferIsValid(lbuf))
30463046
{

src/backend/access/heap/heapam.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8191,13 +8191,7 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
81918191
* blocks).
81928192
*/
81938193
if (bottomup_final_block)
8194-
{
8195-
appendStringInfo(&delstate->debugstr,
8196-
"finished up on heap block %u (having accessed %d blocks in total) because satisfactory amount of space can be freed\n",
8197-
blkno, nblocksaccessed);
8198-
81998194
break;
8200-
}
82018195

82028196
/*
82038197
* Give up when we didn't enable our caller to free any
@@ -8206,12 +8200,7 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
82068200
* we keep the cost of bottom-up deletion under control.
82078201
*/
82088202
if (nblocksaccessed >= 1 && actualfreespace == lastfreespace)
8209-
{
8210-
appendStringInfo(&delstate->debugstr,
8211-
"finished up on heap block %u (having accessed %d blocks in total) because it lacks any deletable TIDs\n",
8212-
blkno, nblocksaccessed);
82138203
break;
8214-
}
82158204
lastfreespace = actualfreespace; /* for next time */
82168205

82178206
/*
@@ -8278,7 +8267,6 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
82788267
*/
82798268
index_delete_check_htid(delstate, page, maxoff, htid, istatus);
82808269

8281-
delstate->ncheckedtids++;
82828270
if (istatus->knowndeletable)
82838271
Assert(!delstate->bottomup && !istatus->promising);
82848272
else
@@ -8393,15 +8381,6 @@ heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
83938381
Assert(finalndeltids > 0 || delstate->bottomup);
83948382
delstate->ndeltids = finalndeltids;
83958383

8396-
/*
8397-
* Simple deletion case needs a message matching similar end messages for
8398-
* bottom-up deletion:
8399-
*/
8400-
if (delstate->instrument && !delstate->bottomup)
8401-
appendStringInfo(&delstate->debugstr,
8402-
"finished up on heap block %u (having accessed %d blocks in total)\n",
8403-
blkno, nblocksaccessed);
8404-
84058384
return snapshotConflictHorizon;
84068385
}
84078386

@@ -8731,16 +8710,6 @@ bottomup_sort_and_shrink(TM_IndexDeleteOp *delstate)
87318710
for (int b = 0; b < nblockgroups; b++)
87328711
{
87338712
IndexDeleteCounts *group = blockgroups + b;
8734-
TM_IndexDelete *firstdtid = delstate->deltids + group->ifirsttid;
8735-
8736-
if (delstate->instrument)
8737-
{
8738-
appendStringInfo(&delstate->debugstr,
8739-
"%d. heap block %u has %d/%d promising TIDs and %d/%d TIDs total\n",
8740-
b + 1, ItemPointerGetBlockNumber(&firstdtid->tid),
8741-
group->npromisingtids, group->npromisingtids == 0 ? 0 : Max(pg_nextpower2_32((uint32) group->npromisingtids), 4),
8742-
group->ntids, pg_nextpower2_32((uint32) group->ntids));
8743-
}
87448713

87458714
/* Better off falling back on nhtids with low npromisingtids */
87468715
if (group->npromisingtids <= 4)

src/backend/access/index/genam.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,8 @@ index_compute_xid_horizon_for_tuples(Relation irel,
316316
delstate.bottomup = false;
317317
delstate.bottomupfreespace = 0;
318318
delstate.ndeltids = 0;
319-
delstate.ntidstotal = 0;
320-
delstate.ncheckedtids = 0;
321319
delstate.deltids = palloc(nitems * sizeof(TM_IndexDelete));
322320
delstate.status = palloc(nitems * sizeof(TM_IndexStatus));
323-
delstate.instrument = false;
324321

325322
/* identify what the index tuples about to be deleted point to */
326323
for (int i = 0; i < nitems; i++)

src/backend/access/nbtree/nbtdedup.c

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "access/nbtxlog.h"
1919
#include "access/xloginsert.h"
2020
#include "miscadmin.h"
21-
#include "utils/guc.h"
2221
#include "utils/rel.h"
2322

2423
static void _bt_bottomupdel_finish_pending(Page page, BTDedupState state,
@@ -317,9 +316,6 @@ _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel,
317316
TM_IndexDeleteOp delstate;
318317
bool neverdedup;
319318
int nkeyatts = IndexRelationGetNumberOfKeyAttributes(rel);
320-
int finaldeletedtids;
321-
IndexTuple firstdataitem = NULL,
322-
highkey = NULL;
323319

324320
/* Passed-in newitemsz is MAXALIGNED but does not include line pointer */
325321
newitemsz += sizeof(ItemIdData);
@@ -359,24 +355,9 @@ _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel,
359355
delstate.bottomup = true;
360356
delstate.bottomupfreespace = Max(BLCKSZ / 16, newitemsz);
361357
delstate.ndeltids = 0;
362-
delstate.ntidstotal = 0;
363-
delstate.ncheckedtids = 0;
364358
delstate.deltids = palloc(MaxTIDsPerBTreePage * sizeof(TM_IndexDelete));
365359
delstate.status = palloc(MaxTIDsPerBTreePage * sizeof(TM_IndexStatus));
366360

367-
initStringInfo(&delstate.debugstr);
368-
appendStringInfo(&delstate.debugstr,
369-
"bottom-up deletion of index \"%s\", block %u:\n",
370-
RelationGetRelationName(rel), BufferGetBlockNumber(buf));
371-
delstate.instrument = true;
372-
373-
if (!P_RIGHTMOST(opaque))
374-
{
375-
ItemId itemid = PageGetItemId(page, P_HIKEY);
376-
377-
highkey = (IndexTuple) PageGetItem(page, itemid);
378-
}
379-
380361
minoff = P_FIRSTDATAKEY(opaque);
381362
maxoff = PageGetMaxOffsetNumber(page);
382363
for (offnum = minoff;
@@ -392,7 +373,6 @@ _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel,
392373
{
393374
/* itup starts first pending interval */
394375
_bt_dedup_start_pending(state, itup, offnum);
395-
firstdataitem = itup;
396376
}
397377
else if (_bt_keep_natts_fast(rel, state->base, itup) > nkeyatts &&
398378
_bt_dedup_save_htid(state, itup))
@@ -426,68 +406,12 @@ _bt_bottomupdel_pass(Relation rel, Buffer buf, Relation heapRel,
426406
pfree(state->htids);
427407
pfree(state);
428408

429-
if (delstate.instrument)
430-
{
431-
char *firstdataitemstr = NULL;
432-
char *highkeystr = NULL;
433-
434-
if (!P_RIGHTMOST(opaque))
435-
appendStringInfo(&delstate.debugstr,
436-
"n_tup: %u, including high key\n",
437-
maxoff);
438-
else
439-
appendStringInfo(&delstate.debugstr,
440-
"n_tup: %u, rightmost page lacking high key\n",
441-
maxoff);
442-
appendStringInfo(&delstate.debugstr, "left sib: %u, right sib: %u\n",
443-
opaque->btpo_prev,
444-
opaque->btpo_next);
445-
446-
if (firstdataitem)
447-
firstdataitemstr = _nbtree_print_itup(firstdataitem, rel);
448-
appendStringInfo(&delstate.debugstr, "first: %s\n",
449-
firstdataitemstr);
450-
if (highkey)
451-
highkeystr = _nbtree_print_itup(highkey, rel);
452-
453-
appendStringInfo(&delstate.debugstr, "h_key: %s\n",
454-
highkeystr);
455-
456-
if (firstdataitemstr)
457-
pfree(firstdataitemstr);
458-
if (highkeystr)
459-
pfree(highkeystr);
460-
}
461-
462-
/*
463-
* Bottom-up deletion always passes every TID on page, so just use that
464-
* count for count of all TIDs on page:
465-
*/
466-
delstate.ntidstotal = delstate.ndeltids;
467-
468409
/* Ask tableam which TIDs are deletable, then physically delete them */
469-
finaldeletedtids = _bt_delitems_delete_check(rel, buf, heapRel, &delstate);
410+
_bt_delitems_delete_check(rel, buf, heapRel, &delstate);
470411

471412
pfree(delstate.deltids);
472413
pfree(delstate.status);
473414

474-
if (delstate.instrument)
475-
{
476-
Size exactfree = PageGetExactFreeSpace(page);
477-
bool rval = (exactfree >= Max(BLCKSZ / 24, newitemsz));
478-
479-
/* Deliberately omit \n here: */
480-
appendStringInfo(&am 2851 p;delstate.debugstr,
481-
"results: exact free space %zu, avoided split-or-dedup '%s', exact TIDs deleted %d",
482-
exactfree, (rval ? "yes" : "no"), finaldeletedtids);
483-
484-
if (log_btree_verbosity >= 2)
485-
ereport(LOG,
486-
(errmsg_internal("%s", delstate.debugstr.data)));
487-
}
488-
489-
pfree(delstate.debugstr.data);
490-
491415
/* Report "success" to caller unconditionally to avoid deduplication */
492416
if (neverdedup)
493417
return true;

0 commit comments

Comments
 (0)
0