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 1sCLri-0050v8-NN for pgsql-hackers@arkaria.postgresql.org; Wed, 29 May 2024 16:09:28 +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 1sCLrh-00Fly4-2P for pgsql-hackers@arkaria.postgresql.org; Wed, 29 May 2024 16:09:25 +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 1sCLrg-00Flxv-OX for pgsql-hackers@lists.postgresql.org; Wed, 29 May 2024 16:09:24 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sCLrd-002Xby-QJ for pgsql-hackers@postgresql.org; Wed, 29 May 2024 16:09:23 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-627efad69b4so21685297b3.3 for ; Wed, 29 May 2024 09:09:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716998961; x=1717603761; darn=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=mJjWmlGbVbThOhYuBXhGJxMUuFtvxRT08Jn19m+qlQQ=; b=VvmDNWHA1cRKVXDfm1WDIp3l1CZut1yNNUwKhz2eogu480tBM7Uxm6dx8iPiTucZUa MnSsKxHa2nGyjNjkr+fsYNe8l+0Ol6A8OD2knwjsADbScr0mlv5Bvy+zJ0RixlkOQiUQ BxOW6J6y/08CQ7dhc/EUTIKwaSShyAr4qoUrty9XefKarrBCglTQ4Kwo9p1dlVZpqjVt L0hjrXPWJrbWyPupyV9SDO/brRh7/jhlgasMAKvQfmYZ4QbgGbtxrtw5fI7SxvC8q3BK Ra7bBDUI1EnIHTG48Dcjl6exNu/qZCQ1NIv4q1neGYFflV6GBBHCY600PnL87BHcUeK8 /xcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716998961; x=1717603761; 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=mJjWmlGbVbThOhYuBXhGJxMUuFtvxRT08Jn19m+qlQQ=; b=vKT2yvjLNrTR0EBJ/9wMMDuohvOpMGh7BJ5duidODbWwMNNJC316X1rpyVVLoNIZY9 jN1UxRZK2q/ox6qQpFYBcOafYrz/NLCzx01rU3hCqJlFiTA15ANjjyC6Niu+eWbAiyKq jOPt2LB43WlFSDk7RCY8pcamrZ6IfyoIY+2JZ85dqfBWYFFQxfYDYWxQs/tTmfEzjO8o PHPWS03Ji+0ijm2vrmFTh4Iaw+hL+IfIh2d2fGEeQ5aetch8sstuctqnNu7eqRkHb7NN nQkmGS7uj844/pcmj/AFDiHW7tGd0GE6ge9yYxLlZ/E3OTJYuP7bjpEdPidNg+ozYQnA rtlQ== X-Gm-Message-State: AOJu0Yz9BCJRL3ppTI1z26tDfrau+r70kqnft/JwjeDS8kg+3Tfxkq5i cB7HpAIqnTv909K9CJfOgH7zPEeV6WX+bl8klV29ZDJSa6epwGJo5WupfvzWTNKlkGOb9R76Xu9 Hu8N1WK+pvquk+H866MzjqqSQGL4= X-Google-Smtp-Source: AGHT+IGzYazD7En8Y7egnMps1/pD1ipEzQuA8JaxDLj9xhvKZganjabEhOrK/75tdqZEfPJy0M8Yo9C7HCk5CsJu+jo= X-Received: by 2002:a0d:d706:0:b0:617:c578:332c with SMTP id 00721157ae682-62a08d39ddfmr155515127b3.4.1716998960566; Wed, 29 May 2024 09:09:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: vignesh C Date: Wed, 29 May 2024 21:26:12 +0530 Message-ID: Subject: Re: 001_rep_changes.pl fails due to publisher stuck on shutdown To: Alexander Lakhin Cc: pgsql-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 Wed, 29 May 2024 at 16:30, Alexander Lakhin wrote: > > Hello hackers, > > As a recent buildfarm test failure [1] shows: > [14:33:02.374](0.333s) ok 23 - update works with dropped subscriber colum= n > ### Stopping node "publisher" using mode fast > # Running: pg_ctl -D > /home/bf/bf-build/adder/HEAD/pgsql.build/testrun/subscription/001_rep_cha= nges/data/t_001_rep_changes_publisher_data/pgdata > -m fast stop > waiting for server to shut down.. ... ... ... .. failed > pg_ctl: server does not shut down > # pg_ctl stop failed: 256 > # Postmaster PID for node "publisher" is 2222549 > [14:39:04.375](362.001s) Bail out! pg_ctl stop failed > > 001_rep_changes_publisher.log > 2024-05-16 14:33:02.907 UTC [2238704][client backend][4/22:0] LOG: statem= ent: DELETE FROM tab_rep > 2024-05-16 14:33:02.925 UTC [2238704][client backend][:0] LOG: disconnect= ion: session time: 0:00:00.078 user=3Dbf > database=3Dpostgres host=3D[local] > 2024-05-16 14:33:02.939 UTC [2222549][postmaster][:0] LOG: received fast= shutdown request > 2024-05-16 14:33:03.000 UTC [2222549][postmaster][:0] LOG: aborting any = active transactions > 2024-05-16 14:33:03.049 UTC [2222549][postmaster][:0] LOG: background wor= ker "logical replication launcher" (PID > 2223110) exited with exit code 1 > 2024-05-16 14:33:03.062 UTC [2222901][checkpointer][:0] LOG: shutting dow= n > 2024-05-16 14:39:04.377 UTC [2222549][postmaster][:0] LOG: received imme= diate shutdown request > 2024-05-16 14:39:04.382 UTC [2222549][postmaster][:0] LOG: database syst= em is shut down > > the publisher node may hang on stopping. > > I reproduced the failure (with aggressive autovacuum) locally and > discovered that it happens because: > 1) checkpointer calls WalSndInitStopping() (which sends > PROCSIG_WALSND_INIT_STOPPING to walsender), and then spins inside > WalSndWaitStopping() indefinitely, because: > 2) walsender receives the signal, sets got_STOPPING =3D true, but can't e= xit > WalSndLoop(): > 3) it never sets got_SIGUSR2 (to get into WalSndDone()) in > XLogSendLogical(): > 4) it never sets WalSndCaughtUp to true: > 5) logical_decoding_ctx->reader->EndRecPtr can't reach flushPtr in > XLogSendLogical(): > 6) EndRecPtr doesn't advance in XLogNextRecord(): > 7) XLogDecodeNextRecord() fails do decode a record that crosses a page > boundary: > 8) ReadPageInternal() (commented "Wait for the next page to become > available") constantly returns XLREAD_FAIL: > 9) state->routine.page_read()/logical_read_xlog_page() constantly returns > -1: > 10) flushptr =3D WalSndWaitForWal() stops advancing, because > got_STOPPING =3D=3D true (see 2). > > That is, walsender doesn't let itself to catch up, if it gets the stop > signal when it's lagging behind and decoding a record requires reading > the next wal page. > > Please look at the reproducing test (based on 001_rep_changes.pl) attache= d. > If fails for me as below: > # 17 > Bailout called. Further testing stopped: pg_ctl stop failed > FAILED--Further testing stopped: pg_ctl stop failed > make: *** [Makefile:21: check] =D0=9E=D1=88=D0=B8=D0=B1=D0=BA=D0=B0 255 Thank you, Alexander, for sharing the script. I was able to reproduce the issue using the provided script. Furthermore, while investigating its origins, I discovered that this problem persists across all branches up to PG10 (the script needs slight adjustments to run it on older versions). It's worth noting that this issue isn't a result of recent version changes. Regards, Vignesh