feat: add cooperative vacuum cancellation for background merge workers#3970
feat: add cooperative vacuum cancellation for background merge workers#3970
Conversation
Implements advisory lock signaling so VACUUM can request background merge workers to exit early instead of waiting for long-running merges to complete.
There was a problem hiding this comment.
pg_search single-server.toml Performance - TPS
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Aggregate Custom Scan - Primary - tps |
135.71059014690658 median tps |
124.17038357125155 median tps |
0.91 |
Delete values - Primary - tps |
2974.5644707756433 median tps |
3029.1606401204835 median tps |
1.02 |
Index Scan - Primary - tps |
484.5661187248814 median tps |
435.752063933696 median tps |
0.90 |
Insert value - Primary - tps |
2998.897955038312 median tps |
2967.7676046982997 median tps |
0.99 |
Mixed Fast Field Scan - Primary - tps |
514.2180892728518 median tps |
481.8375492714087 median tps |
0.94 |
Normal Scan - Primary - tps |
531.6328376957056 median tps |
557.3741174092116 median tps |
1.05 |
Update random values - Primary - tps |
1876.6365886639194 median tps |
1843.7232233982077 median tps |
0.98 |
Vacuum - Primary - tps |
201.75132816623972 median tps |
33.15155390785683 median tps |
0.16 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search single-server.toml Performance - Other Metrics
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Aggregate Custom Scan - Primary - cpu |
9.239654 median cpu |
9.248554 median cpu |
1.00 |
Aggregate Custom Scan - Primary - mem |
60.55078125 median mem |
59.94140625 median mem |
1.01 |
Delete values - Primary - cpu |
4.6332045 median cpu |
4.628737 median cpu |
1.00 |
Delete values - Primary - mem |
32.2734375 median mem |
33.53125 median mem |
0.96 |
Index Scan - Primary - cpu |
4.6332045 median cpu |
4.619827 median cpu |
1.00 |
Index Scan - Primary - mem |
58.8828125 median mem |
58.1953125 median mem |
1.01 |
Insert value - Primary - cpu |
4.6332045 median cpu |
4.628737 median cpu |
1.00 |
Insert value - Primary - mem |
46.7421875 median mem |
46.78125 median mem |
1.00 |
Mixed Fast Field Scan - Primary - cpu |
4.6376815 median cpu |
4.6376815 median cpu |
1 |
Mixed Fast Field Scan - Primary - mem |
59.828125 median mem |
59.01171875 median mem |
1.01 |
Monitor Index Size - Primary - block_count |
1813 median block_count |
1752 median block_count |
1.03 |
Monitor Index Size - Primary - segment_count |
7 median segment_count |
14 median segment_count |
0.50 |
Normal Scan - Primary - cpu |
4.6376815 median cpu |
4.6332045 median cpu |
1.00 |
Normal Scan - Primary - mem |
59.8984375 median mem |
59.02734375 median mem |
1.01 |
Update random values - Primary - cpu |
4.6376815 median cpu |
4.624277 median cpu |
1.00 |
Update random values - Primary - mem |
49.375 median mem |
49.05859375 median mem |
1.01 |
Vacuum - Primary - cpu |
4.619827 median cpu |
4.624277 median cpu |
1.00 |
Vacuum - Primary - mem |
50.6875 median mem |
52.125 median mem |
0.97 |
This comment was automatically generated by workflow using github-action-benchmark.
paradedb-bot
left a comment
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'pg_search single-server.toml Performance - Other Metrics'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.
| Benchmark suite | Current: c128972 | Previous: 31db3d4 | Ratio |
|---|---|---|---|
Monitor Index Size - Primary - segment_count |
12 median segment_count |
9 median segment_count |
1.33 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @mithuncy
There was a problem hiding this comment.
pg_search bulk-updates.toml Performance - TPS
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Bulk Update - Primary - tps |
7.360380075725288 median tps |
7.470730782020574 median tps |
1.01 |
Count Query - Primary - tps |
5.449698880974654 median tps |
5.303795233175175 median tps |
0.97 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search bulk-updates.toml Performance - Other Metrics
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Bulk Update - Primary - cpu |
23.188406 median cpu |
23.188406 median cpu |
1 |
Bulk Update - Primary - mem |
233.43359375 median mem |
233.19140625 median mem |
1.00 |
Count Query - Primary - cpu |
23.27837 median cpu |
23.27837 median cpu |
1 |
Count Query - Primary - mem |
173.00390625 median mem |
172.49609375 median mem |
1.00 |
Monitor Index Size - Primary - block_count |
33839 median block_count |
33924 median block_count |
1.00 |
Monitor Index Size - Primary - segment_count |
78 median segment_count |
78 median segment_count |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search wide-table.toml Performance - TPS
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Bulk Update - Primary - tps |
1119.959666873194 median tps |
1095.7059860060417 median tps |
0.98 |
Single Insert - Primary - tps |
1248.7232889045272 median tps |
1221.5611024462364 median tps |
0.98 |
Single Update - Primary - tps |
1918.8552437910487 median tps |
1788.3173299708396 median tps |
0.93 |
Top N - Primary - tps |
5.56840301505131 median tps |
5.272209352600935 median tps |
0.95 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search wide-table.toml Performance - Other Metrics
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Background Merger - Primary - background_merging |
0 median background_merging |
0 median background_merging |
1 |
Background Merger - Primary - cpu |
4.6647234 median cpu |
4.660194 median cpu |
1.00 |
Background Merger - Primary - mem |
22.72265625 median mem |
23.359375 median mem |
0.97 |
Bulk Update - Primary - cpu |
4.669261 median cpu |
4.6647234 median cpu |
1.00 |
Bulk Update - Primary - mem |
165.8515625 median mem |
166.37890625 median mem |
1.00 |
Monitor Index Size - Primary - block_count |
51169 median block_count |
51439 median block_count |
0.99 |
Monitor Index Size - Primary - segment_count |
45 median segment_count |
45 median segment_count |
1 |
Single Insert - Primary - cpu |
4.669261 median cpu |
4.660194 median cpu |
1.00 |
Single Insert - Primary - mem |
122.390625 median mem |
122.2578125 median mem |
1.00 |
Single Update - Primary - cpu |
4.6647234 median cpu |
4.660194 median cpu |
1.00 |
Single Update - Primary - mem |
165.65625 median mem |
166.07421875 median mem |
1.00 |
Top N - Primary - cpu |
23.391813 median cpu |
23.346306 median cpu |
1.00 |
Top N - Primary - mem |
160.37890625 median mem |
160.16015625 median mem |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search background-merge.toml Performance - TPS
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Custom scan - Primary - tps |
31.379323231382426 median tps |
29.930939450767287 median tps |
0.95 |
Delete value - Primary - tps |
235.03153945887243 median tps |
237.46141300334767 median tps |
1.01 |
Insert value - Primary - tps |
1836.8559993486444 median tps |
1916.0198971661046 median tps |
1.04 |
Update random values - Primary - tps |
162.80715884296455 median tps |
160.56086531546595 median tps |
0.99 |
Vacuum - Primary - tps |
14.679819710056412 median tps |
14.302739204359476 median tps |
0.97 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search background-merge.toml Performance - Other Metrics
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Custom scan - Primary - cpu |
18.58664 median cpu |
18.568666 median cpu |
1.00 |
Custom scan - Primary - mem |
168.09765625 median mem |
173.36328125 median mem |
0.97 |
Delete value - Primary - cpu |
4.6421666 median cpu |
4.6376815 median cpu |
1.00 |
Delete value - Primary - mem |
120.04296875 median mem |
116.95703125 median mem |
1.03 |
Insert value - Primary - cpu |
4.6332045 median cpu |
4.6332045 median cpu |
1 |
Insert value - Primary - mem |
123.1796875 median mem |
125.9140625 median mem |
0.98 |
Monitor Segment Count - Primary - block_count |
13738 median block_count |
13488 median block_count |
1.02 |
Monitor Segment Count - Primary - cpu |
4.6332045 median cpu |
4.624277 median cpu |
1.00 |
Monitor Segment Count - Primary - mem |
95.62890625 median mem |
97.73828125 median mem |
0.98 |
Monitor Segment Count - Primary - segment_count |
24 median segment_count |
24 median segment_count |
1 |
Update random values - Primary - cpu |
9.204219 median cpu |
9.213051 median cpu |
1.00 |
Update random values - Primary - mem |
160.51953125 median mem |
159.83203125 median mem |
1.00 |
Vacuum - Primary - cpu |
13.88621 median cpu |
13.872832 median cpu |
1.00 |
Vacuum - Primary - mem |
168.47265625 median mem |
167.89453125 median mem |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search logical-replication.toml Performance - TPS
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Custom Scan - Subscriber - tps |
548.436318196123 median tps |
599.2425299670981 median tps |
1.09 |
Index Only Scan - Subscriber - tps |
612.0315185155524 median tps |
588.0575058061426 median tps |
0.96 |
Parallel Custom Scan - Subscriber - tps |
85.87406770469411 median tps |
86.85412972271462 median tps |
1.01 |
Top N - Subscriber - tps |
108.57808892560485 median tps |
109.23165070608782 median tps |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
pg_search logical-replication.toml Performance - Other Metrics
Details
| Benchmark suite | Current: 1518839 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Custom Scan - Subscriber - cpu |
4.5757866 median cpu |
4.5757866 median cpu |
1 |
Custom Scan - Subscriber - mem |
47.32421875 median mem |
47.50390625 median mem |
1.00 |
Delete values - Publisher - cpu |
4.524034 median cpu |
4.5801525 median cpu |
0.99 |
Delete values - Publisher - mem |
30.01953125 median mem |
30.19140625 median mem |
0.99 |
Find by ctid - Subscriber - cpu |
9.116809 median cpu |
9.082309 median cpu |
1.00 |
Find by ctid - Subscriber - mem |
50.06640625 median mem |
49.67578125 median mem |
1.01 |
Index Only Scan - Subscriber - cpu |
4.5757866 median cpu |
4.5757866 median cpu |
1 |
Index Only Scan - Subscriber - mem |
46.9765625 median mem |
46.9921875 median mem |
1.00 |
Index Size Info - Subscriber - cpu |
4.5714283 median cpu |
4.5714283 median cpu |
1 |
Index Size Info - Subscriber - mem |
30.8515625 median mem |
30.8359375 median mem |
1.00 |
Index Size Info - Subscriber - pages |
1111 median pages |
1095 median pages |
1.01 |
Index Size Info - Subscriber - relation_size:MB |
8.6796875 median relation_size:MB |
8.5546875 median relation_size:MB |
1.01 |
Index Size Info - Subscriber - segment_count |
9 median segment_count |
10 median segment_count |
0.90 |
Insert value A - Publisher - cpu |
4.5801525 median cpu |
4.5757866 median cpu |
1.00 |
Insert value A - Publisher - mem |
27.60546875 median mem |
27.65625 median mem |
1.00 |
Insert value B - Publisher - cpu |
4.5584044 median cpu |
4.58891 median cpu |
0.99 |
Insert value B - Publisher - mem |
27.67578125 median mem |
27.796875 median mem |
1.00 |
Parallel Custom Scan - Subscriber - cpu |
4.6021094 median cpu |
4.6021094 median cpu |
1 |
Parallel Custom Scan - Subscriber - mem |
45.41796875 median mem |
45.84375 median mem |
0.99 |
| `SELECT | |||
| pid, | |||
| pg_wal_lsn_diff(sent_lsn, replay_lsn) AS replication_lag, | |||
| application_name::text, | |||
| state::text | |||
| FROM pg_stat_replication; - Publisher - replication_lag:MB` | 0 median replication_lag:MB |
0 median replication_lag:MB |
1 |
Top N - Subscriber - cpu |
4.5757866 median cpu |
4.5757866 median cpu |
1 |
Top N - Subscriber - mem |
46.13671875 median mem |
45.8671875 median mem |
1.01 |
Update 1..9 - Publisher - cpu |
4.5801525 median cpu |
4.5757866 median cpu |
1.00 |
Update 1..9 - Publisher - mem |
30.69140625 median mem |
30.6015625 median mem |
1.00 |
Update 10,11 - Publisher - cpu |
4.567079 median cpu |
4.5584044 median cpu |
1.00 |
Update 10,11 - Publisher - mem |
30.5625 median mem |
30.86328125 median mem |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
paradedb-bot
left a comment
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'pg_search logical-replication.toml Performance - Other Metrics'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.
| Benchmark suite | Current: c128972 | Previous: 31db3d4 | Ratio |
|---|---|---|---|
Index Size Info - Subscriber - segment_count |
10 median segment_count |
8 median segment_count |
1.25 |
Insert value B - Publisher - cpu |
4.567079 median cpu |
0 median cpu |
+∞ |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @mithuncy
Review changes: - Rename new_session to conditional_lock_session (makes intent clearer) - Move VacuumSignal, VACUUM_SIGNAL_KEY_BASE, vacuum_wants_cancel to delete.rs - Inline acquire_cleanup_lock_for_vacuum logic directly into ambulkdelete - Rename is_vacuum_signaled to vacuum_wants_cancel (clearer purpose) - Rename check_vacuum_signal parameter to is_background (better semantics) - Keep PgTryBuilder for defensive safety against unlikely PostgreSQL errors
paradedb-bot
left a comment
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'pg_search logical-replication.toml Performance - TPS'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.
| Benchmark suite | Current: 1542204 | Previous: 05ef136 | Ratio |
|---|---|---|---|
Custom Scan - Subscriber - tps |
535.1502678315223 median tps |
599.2425299670981 median tps |
1.12 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @rebasedming
- Rename is_signaled() to wants_cancel() for clarity from caller's perspective - Simplify boolean return: use !acquired instead of if/else - Make VacuumSignal pub(crate) and remove vacuum_wants_cancel wrapper - Update merge.rs to use VacuumSignal directly















Summary
Implements advisory lock signaling so VACUUM can request background merge workers to exit early instead of waiting for long-running merges to complete.
Closes #3528