Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit958cfbc

Browse files
Remove unneeded field from VACUUM state.
Bugfix commit5fc8937 effectively made the lock_waiter_detected fieldfrom vacuumlazy.c's global state struct into private state owned bylazy_truncate_heap(). Finish this off by replacing the struct fieldwith a local variable.
1 parentad2da24 commit958cfbc

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

‎src/backend/access/heap/vacuumlazy.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ typedef struct LVRelState
351351
BlockNumberpages_removed;/* pages remove by truncation */
352352
BlockNumberlpdead_item_pages;/* # pages with LP_DEAD items */
353353
BlockNumbernonempty_pages;/* actually, last nonempty page + 1 */
354-
boollock_waiter_detected;
355354

356355
/* Statistics output by us, for table */
357356
doublenew_rel_tuples;/* new estimated total # of tuples */
@@ -439,7 +438,8 @@ static IndexBulkDeleteResult *lazy_cleanup_one_index(Relation indrel,
439438
staticboolshould_attempt_truncation(LVRelState*vacrel,
440439
VacuumParams*params);
441440
staticvoidlazy_truncate_heap(LVRelState*vacrel);
442-
staticBlockNumbercount_nondeletable_pages(LVRelState*vacrel);
441+
staticBlockNumbercount_nondeletable_pages(LVRelState*vacrel,
442+
bool*lock_waiter_detected);
443443
staticlongcompute_max_dead_tuples(BlockNumberrelblocks,boolhasindex);
444444
staticvoidlazy_space_alloc(LVRelState*vacrel,intnworkers,
445445
BlockNumberrelblocks);
@@ -929,7 +929,6 @@ lazy_scan_heap(LVRelState *vacrel, VacuumParams *params, bool aggressive)
929929
vacrel->pages_removed=0;
930930
vacrel->lpdead_item_pages=0;
931931
vacrel->nonempty_pages=0;
932-
vacrel->lock_waiter_detected= false;
933932

934933
/* Initialize instrumentation counters */
935934
vacrel->num_index_scans=0;
@@ -3165,6 +3164,7 @@ lazy_truncate_heap(LVRelState *vacrel)
31653164
{
31663165
BlockNumberold_rel_pages=vacrel->rel_pages;
31673166
BlockNumbernew_rel_pages;
3167+
boollock_waiter_detected;
31683168
intlock_retry;
31693169

31703170
/* Report that we are now truncating */
@@ -3187,7 +3187,7 @@ lazy_truncate_heap(LVRelState *vacrel)
31873187
* (which is quite possible considering we already hold a lower-grade
31883188
* lock).
31893189
*/
3190-
vacrel->lock_waiter_detected= false;
3190+
lock_waiter_detected= false;
31913191
lock_retry=0;
31923192
while (true)
31933193
{
@@ -3207,7 +3207,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32073207
* We failed to establish the lock in the specified number of
32083208
* retries. This means we give up truncating.
32093209
*/
3210-
vacrel->lock_waiter_detected= true;
3210+
lock_waiter_detected= true;
32113211
ereport(elevel,
32123212
(errmsg("\"%s\": stopping truncate due to conflicting lock request",
32133213
vacrel->relname)));
@@ -3242,7 +3242,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32423242
* other backends could have added tuples to these pages whilst we
32433243
* were vacuuming.
32443244
*/
3245-
new_rel_pages=count_nondeletable_pages(vacrel);
3245+
new_rel_pages=count_nondeletable_pages(vacrel,&lock_waiter_detected);
32463246
vacrel->blkno=new_rel_pages;
32473247

32483248
if (new_rel_pages >=old_rel_pages)
@@ -3281,8 +3281,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32813281
errdetail_internal("%s",
32823282
pg_rusage_show(&ru0))));
32833283
old_rel_pages=new_rel_pages;
3284-
}while (new_rel_pages>vacrel->nonempty_pages&&
3285-
vacrel->lock_waiter_detected);
3284+
}while (new_rel_pages>vacrel->nonempty_pages&&lock_waiter_detected);
32863285
}
32873286

32883287
/*
@@ -3291,7 +3290,7 @@ lazy_truncate_heap(LVRelState *vacrel)
32913290
* Returns number of nondeletable pages (last nonempty page + 1).
32923291
*/
32933292
staticBlockNumber
3294-
count_nondeletable_pages(LVRelState*vacrel)
3293+
count_nondeletable_pages(LVRelState*vacrel,bool*lock_waiter_detected)
32953294
{
32963295
BlockNumberblkno;
32973296
BlockNumberprefetchedUntil;
@@ -3343,7 +3342,7 @@ count_nondeletable_pages(LVRelState *vacrel)
33433342
(errmsg("\"%s\": suspending truncate due to conflicting lock request",
33443343
vacrel->relname)));
33453344

3346-
vacrel->lock_waiter_detected= true;
3345+
*lock_waiter_detected= true;
33473346
returnblkno;
33483347
}
33493348
starttime=currenttime;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp