Call lazy_check_wraparound_failsafe earlier for parallel vacuum - Mailing list pgsql-hackers

From Imseih (AWS), Sami
Subject Call lazy_check_wraparound_failsafe earlier for parallel vacuum
Date
Msg-id 401CE010-4049-4B94-9961-0B610A5D254D@amazon.com
Whole thread Raw
Responses Re: Call lazy_check_wraparound_failsafe earlier for parallel vacuum
List pgsql-hackers

While looking through vacuum code, I noticed that

unlike non-parallel vacuum, parallel vacuum only gets

a failsafe check after an entire index cycle completes.

 

In vacuumlazy.c, lazy_check_wraparound_failsafe is checked

after every index completes, while in parallel, it is checked

after an entire index cycle completed.

 

if (!ParallelVacuumIsActive(vacrel))

                {

                                for (int idx = 0; idx < vacrel->nindexes; idx++)

                                {

                                                Relation                indrel = vacrel->indrels[idx];

                                                IndexBulkDeleteResult *istat = vacrel->indstats[idx];

 

                                                vacrel->indstats[idx] =

                                                                lazy_vacuum_one_index(indrel, istat, vacrel->old_live_tuples,

                                                                                                                                                  vacrel);

 

                                                /*

                                                * Done vacuuming an index. Increment the indexes completed

                                                */

                                                pgstat_progress_update_param(PROGRESS_VACUUM_INDEX_COMPLETED,

                                                                                                                                                                idx + 1);

 

                                                if (lazy_check_wraparound_failsafe(vacrel))

                                                {

                                                                /* Wraparound emergency -- end current index scan */

                                                                allindexes = false;

                                                                break;

                                                }

                                }

                }

                else

                {

                                /* Outsource everything to parallel variant */

                                parallel_vacuum_bulkdel_all_indexes(vacrel->pvs, vacrel->old_live_tuples,

                                                                                                                                                                                vacrel->num_index_scans);

 

                                /*

                                * Do a postcheck to consider applying wraparound failsafe now.  Note

                                * that parallel VACUUM only gets the precheck and this postcheck.

                                */

                                if (lazy_check_wraparound_failsafe(vacrel))

                                                allindexes = false;

                }

 

When a user is running a parallel vacuum and the vacuum is long running

due to many large indexes, it would make sense to check for failsafe earlier.

 

Also, checking after every index for parallel vacuum will provide the same

failsafe behavior for both parallel and non-parallel vacuums.

 

To make this work, it is possible to call lazy_check_wraparound_failsafe

inside parallel_vacuum_process_unsafe_indexes and

parallel_vacuum_process_safe_indexes of vacuumparallel.c

 

 

Regards,

 

Sami Imseih

Amazon Web Services (AWS)

 

pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Update some more ObjectType switch statements to not have default
Next
From: Alvaro Herrera
Date:
Subject: Re: [PATCH] Teach pg_waldump to extract FPIs from the WAL