This is an automated email from the ASF dual-hosted git repository.
yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new f00c2b4a581 AO vacuum: CommandCounterIncrement before
AppendOptimizedTruncateToEOF
f00c2b4a581 is described below
commit f00c2b4a581ac58dcaa877e87e20d157f3065ec3
Author: Jianghua Yang <[email protected]>
AuthorDate: Fri May 15 23:10:16 2026 +0800
AO vacuum: CommandCounterIncrement before AppendOptimizedTruncateToEOF
ClearAOCSFileSegInfo/ClearFileSegInfo (called from
ao_vacuum_rel_recycle_dead_segments) updates pg_aoseg rows via
simple_heap_update, which assigns the current CommandId to the new tuple.
AppendOptimizedTruncateToEOF then opens a catalog snapshot via
GetCatalogSnapshot, which also uses GetCurrentCommandId. Because both
operations share the same CommandId, the just-zeroed rows are invisible
to the snapshot (cid >= snapshot->curcid), while the old rows with their
original non-zero EOF values remain visible. TruncateAOSegmentFile then
sees a 0-byte physical file but a non-zero logical EOF and raises:
"file size smaller than logical eof"
Advancing the command counter before AppendOptimizedTruncateToEOF
ensures the zeroed rows are visible to its catalog snapshot (their cid
is now strictly less than the new curcid).
Fixes: https://github.com/apache/cloudberry/issues/1746
---
src/backend/commands/vacuum_ao.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/backend/commands/vacuum_ao.c b/src/backend/commands/vacuum_ao.c
index 466fe30665d..dff6ecf332d 100644
--- a/src/backend/commands/vacuum_ao.c
+++ b/src/backend/commands/vacuum_ao.c
@@ -224,6 +224,14 @@ ao_vacuum_rel_pre_cleanup(Relation onerel, VacuumParams
*params, BufferAccessStr
*/
ao_vacuum_rel_recycle_dead_segments(onerel, params, bstrategy,
vacrelstats);
+ /*
+ * Make the pg_aoseg updates above visible to
AppendOptimizedTruncateToEOF's
+ * catalog snapshot; without this the zeroed-eof rows are invisible
(same
+ * CommandId) and the old non-zero-eof rows appear live, triggering
"file
+ * size smaller than logical eof".
+ */
+ CommandCounterIncrement();
+
/*
* Also truncate all live segments to the EOF values stored in pg_aoseg.
* This releases space left behind by aborted inserts.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]