Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZ9iV-00GltL-KS for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2024 13:50:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sZ9iT-0078hB-GV for pgsql-hackers@arkaria.postgresql.org; Wed, 31 Jul 2024 13:50:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sZ9iT-0078h0-6Z for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2024 13:50:09 +0000 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sZ9iQ-002NnR-1b for pgsql-hackers@lists.postgresql.org; Wed, 31 Jul 2024 13:50:07 +0000 Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-e0878971aa9so790206276.0 for ; Wed, 31 Jul 2024 06:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722433805; x=1723038605; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=h0EBy3d32Z2jfWTp0IDJcItWx+6W3GYLM1+v6nMuOnA=; b=Q6UKOtA5HuBz/UkjrWbpDKTy1KSsmwO5QjtKdygnVd/7/wDCm57MJ+2ehFlgz1pKGL cAxkjOUiUeZx44KnKpU58qdCHPZKWLNnrwsDo5gHy8dMYYPU5z6ELIWPbE4VFSc9bI5/ EF+hRLKSgO/gXF0fyXR4YMTizq6lZyz/2cYBZW//706zazSBO3eY1DK6RPMb+ZMLVz9b KhGZbXNlsOipasyvXBSp5AYRpPNQfzncUDDAgM2KUU0xjcV1MyQ/3rBsOCBhF4OS4Sk+ WqWcjxnnBZuQ3kJVwlNU8t6n+UyFCymDe3R1gFL/rBjvP707tQwTivLL+NV8NPSQEUDw srOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722433805; x=1723038605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h0EBy3d32Z2jfWTp0IDJcItWx+6W3GYLM1+v6nMuOnA=; b=rXeUtO8gi4dEuYditecBTrRnFzERrZnIXoK6IsHMmDAfjixNWIs2gQ0XzBbdcpmeYR S7Hd9xzcUbHg9XZx8BK6hP5Rgy0R75ajTYI+GLLhFzE528cNgmHNfEJkTPFmZD93zpvs bq+nO35Jj9Iz03uFOyWDnKdim7dhL0BKdhNv7tom2P1I7o36wePw7o3rCaQM5l0/qBzc 93wT2sVyC/eP/h6f4ofrVhOWgijNkzaleSF6EC7Y1NPPjKuNo+SKl09BueKY/vIxglEM 4YTPnf7RsHwxHQZ5VsTJm2W4CnFB7qeX1Mil2R/FxaI6O+7I/M6Nh8y6SrI0kiqZUNNT fehg== X-Forwarded-Encrypted: i=1; AJvYcCU2ulO9t9Hz58TpdWxqIioCCNZjTRj/9CMsk2Sdx7DIUPilVzB4qgCnWiJ0Rr+YoedST1O/x3MhjzRHPDjnW+0ylvi/XOAT3vaBrgWvFYI9mjiZ X-Gm-Message-State: AOJu0YymVEqyQTnJd+aN4UdFyAbAjCPTBZNuVEh2XdBrOGu1orvp9Vg3 JDYPIb7wdhKwuhkp/q0hXd1uB24BSwj0MNWCh1R5cDenqp+0fUHv1PVmrWdUnMfTtMfs5rtEPwP pzFXuitJ+SO2OXF0jWzleFRQ+Xys= X-Google-Smtp-Source: AGHT+IFkKwExYVI6JExiFl8H2tnsDFXR23FQFvE6HrdCyisC5jj1RWs/ezzssWNr8vZkxg4tr9Pl/jQgH1406YIuyQk= X-Received: by 2002:a5b:386:0:b0:e02:d8f1:5fe with SMTP id 3f1490d57ef6-e0b9e52d81dmr4896736276.25.1722433805318; Wed, 31 Jul 2024 06:50:05 -0700 (PDT) MIME-Version: 1.0 References: <2a6fe324-3008-4e44-9ff6-b5bba9232490@oss.nttdata.com> In-Reply-To: From: Alexander Korotkov Date: Wed, 31 Jul 2024 16:49:54 +0300 Message-ID: Subject: Re: Assertion failure with summarize_wal enabled during pg_createsubscriber To: Robert Haas Cc: Nathan Bossart , Michael Paquier , Fujii Masao , Postgres hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 29, 2024 at 7:20=E2=80=AFPM Robert Haas = wrote: > On Fri, Jul 26, 2024 at 4:10=E2=80=AFPM Alexander Korotkov wrote: > > 0002 could also use pg_indent and pgperltidy. And I have couple other > > notes regarding 0002. > > As Tom said elsewhere, we don't have a practice of requiring perltidy > for every commit, and I normally don't bother. The tree is > pgindent-clean currently so I believe I got that part right. Got it, thanks. > > > In the process of fixing these bugs, I realized that the logic to = wait > > > for WAL summarization to catch up was spread out in a way that mad= e > > > it difficult to reuse properly, so this code refactors things to m= ake > > > it easier. > > > > It would be nice to split refactoring out of material logic changed. > > This way it would be easier to review and would look cleaner in the > > git history. > > I support that idea in general but felt it was overkill in this case: > it's new code, and there was only one existing caller of the function > that got refactored, and I'm not a huge fan of cluttering the git > history with a bunch of tiny little refactoring commits to fix a > single bug. I might have changed it if I'd seen this note before > committing, though. I understand your point. I'm also not huge fan of a flood of small commits. Nevertheless, I find splitting refactoring from other changes generally useful. That could be a single commit of many small refactorings, not many small commits. The point for me is easier review: you can expect refactoring commit to contain "isomorphic" changes, while other commits implementing material logic changes. But that might be a committer preference though. > > > To make this fix work, also teach the WAL summarizer that after a > > > promotion has occurred, no more WAL can appear on the previous > > > timeline: previously, the WAL summarizer wouldn't switch to the ne= w > > > timeline until we actually started writing WAL there, but that mea= nt > > > that when the startup process was waiting for the WAL summarizer, = it > > > was waiting for an action that the summarizer wasn't yet prepared = to > > > take. > > > > I think this is a pretty long sentence, and I'm not sure I can > > understand it correctly. Does startup process wait for the WAL > > summarizer without this patch? If not, it's not clear for me that > > word "previously" doesn't distribute to this part of sentence. > > Breaking this into multiple sentences could improve the clarity for > > me. > > Yes, I think that phrasing is muddled. It's too late to amend the > commit message, but for posterity: I initially thought that I could > fix this bug by just teaching the startup process to wait for WAL > summarization before performing the .partial renaming, but that was > not enough by itself. The problem is that the WAL summarizer would > read all the records that were present in the final WAL file on the > old timeline, but it wouldn't actually write out a summary file, > because that only happens when it reaches XLOG_CHECKPOINT_REDO or a > timeline switch point. Since no WAL had appeared on the new timeline > yet, it didn't view the end of the old timeline as a switch point, so > it just sat there waiting, without ever writing out a file; and the > startup process sat there waiting for it. So the second part of the > fix is to make the WAL summarizer realize that once the startup > process has chosen a new timeline ID, no more WAL is going to appear > on the old timeline, and thus it can (and should) write out the final > summary file for the old timeline and prepare to read WAL from the new > timeline. Great, thank you for the explanation. Now that's clear. ------ Regards, Alexander Korotkov Supabase