From 32a99d1c40598d2c74dfd6b0b475439c35859881 Mon Sep 17 00:00:00 2001 From: April01xxx Date: Fri, 15 Nov 2024 12:10:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=A7=E8=A1=8C=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E7=82=B9=E6=97=B6batch=20double=20write=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=81=A2=E5=A4=8D=E8=B5=B7=E5=A7=8B=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/access/transam/double_write.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/storage/access/transam/double_write.cpp b/src/gausskernel/storage/access/transam/double_write.cpp index f0c8496cc..1ccf9d93b 100644 --- a/src/gausskernel/storage/access/transam/double_write.cpp +++ b/src/gausskernel/storage/access/transam/double_write.cpp @@ -785,9 +785,11 @@ static bool dw_batch_file_recycle(dw_batch_file_context *cxt, uint16 pages_to_wr if (trunc_file) { Assert(AmStartupProcess() || AmCheckpointerProcess() || AmBootstrapProcess() || !IsUnderPostmaster); /* - * Record min flush position for truncate because flush lock is not held during smgrsync. + * Record min flush position and # pages that have been flushed to dw + * file for truncate because flush lock is not held during smgrsync. */ min_idx = get_dw_page_min_idx(cxt->id); + last_flush_page = cxt->flush_page; LWLockRelease(cxt->flush_lock); } else { Assert(AmStartupProcess() || AmPageWriterProcess()); @@ -827,8 +829,8 @@ static bool dw_batch_file_recycle(dw_batch_file_context *cxt, uint16 pages_to_wr */ if (trunc_file) { if (min_idx == 0) { - file_head->start += cxt->flush_page; - cxt->flush_page = 0; + file_head->start += last_flush_page; + cxt->flush_page -= last_flush_page; } else { last_flush_page = min_idx - file_head->start; file_head->start = min_idx;