-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect index->reltuples after VACUUM #217
Conversation
Given the scenario of updating stats during VACUUM: 1) coordinator vacuums and updates stats of its own; 2) then coordinator dispatches vacuum to segments; 3) coordinator combines stats received from segments to overwrite the stats of its own. Because upstream introduced a feature which could skip full index scan uring cleanup of B-tree indexes when possible (refer to: postgres/postgres@857f9c3), there was a case in QD-QEs distributed deployment that some QEs could skip full index scan and stop updating statistics, resulting in QD being unable to collect all QEs' stats thus overwrote a paritial accumulated value to index->reltuples. More interesting, it usually happened starting from the 3rd time of consecutively VACUUM after fresh inserts due to above skipping index scan criteria. This patch is intended to prevent from above issue by two aspects: on QE, do not skip full index scan, report current statistics to QD as requested; on QD, restrict updating statistics only when collecting all QEs' data completely, if the reporting QE number doesn't match the total number of dispatched QEs, no stats update happens.
|
00c7c43
to
fd157d5
Compare
There is conflict in _bt_vacuum_needs_cleanup between CloudberryDB and GPDB. We update the _bt_vacuum_needs_cleanup in CloudberryDB. We enforce update stats when Gp_role is GP_ROLE_EXECUTE, and set estimated_count to false. which in the scan_index We call vac_update_relstats to send back stats to QE. Fix serveral tests due to update stats after vacuum. We keep these tests result same with GPDB.
28060dd
fd157d5
to
28060dd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
closes: #214
Change logs
We enforce all QE to update stats after vacuum in the index, and all QD will collect stats and update the pg_class. Otherwises, only some QE will update stats and send back to QD which left index stats in incomplete state.
Why are the changes needed?
Describe why the changes are necessary.
Does this PR introduce any user-facing change?
no
How was this patch tested?
cherrypick
Contributor's Checklist
Here are some reminders and checklists before/when submitting your pull request, please check them:
make installcheck
make -C src/test installcheck-cbdb-parallel