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 1sCXiX-006HWi-WE for pgsql-hackers@arkaria.postgresql.org; Thu, 30 May 2024 04:48:47 +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 1sCXiW-001GOS-Mj for pgsql-hackers@arkaria.postgresql.org; Thu, 30 May 2024 04:48:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sCXiW-001GOK-AL for pgsql-hackers@lists.postgresql.org; Thu, 30 May 2024 04:48:44 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sCXiQ-001SLJ-Ui for pgsql-hackers@postgresql.org; Thu, 30 May 2024 04:48:43 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2e95a1d5ee2so7163001fa.0 for ; Wed, 29 May 2024 21:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717044518; x=1717649318; 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=OGzvZssvIYXS7gzIthWz9VYP/KF/MwUySd9n/GCkfDg=; b=AY1WF7dl8fza8iroFckNJTeiFpMpKhfUJN0HjuyoKanzEpbKBAGRlisaPmMLaSqOF/ RKuwoFvsFNCWLShjJEDSIDvQA0ZykgwYjMUDhH5kA061fXcOSZ68JbuG6QPnjcaGFmL2 S2+QYPSLaqZu9V1FICpAMmNqASC0jBWudzkHz0fQruoBLQtmx8/Gnd/QkHpfit6DO4uR yCkwDe45Q0YlJ60FcZP0j28Q+QS5v2j3R/ijrzvXiLeuxlVFvybdf9iLb2EXH/6wbOmg 9cK5/Y282pJEFBBQaiRidxGN1n+0ODc0EPFl+0fhwoNgzMHIQwal/XA0iNfrWpdQTPCQ kkfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717044518; x=1717649318; 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=OGzvZssvIYXS7gzIthWz9VYP/KF/MwUySd9n/GCkfDg=; b=nnHDye0NZe5SpNQ7VJBmJq66xfFf4gp71LQR1apUEXpYNIpMp1rGh3hWCco/BfWtxf x+DWTaHW1GSw9GmZOvhu9bKBJSWaCb4Se3wtokoYonGmbFjF7jzZVkAmipLAMGHGv+6R UkSwr2iIORXWlPcP5IWu/rrPdkunRR9XZHKdnX9KSYFQ465s7tSb5FhVvZGlALjCythT Qn1st4DiZ94ieSvLiyZkFBRbv4u3jC9s5o7unEH1ZmA9MrScaEblCgVkJiA/OPFfYatG lSarbdI7TyuXwL3MMxLJY0LSXYC19lDIEQ2ZkABgmEHoVByqWne1Y0oFAC2yjwAadJxL 7r9g== X-Forwarded-Encrypted: i=1; AJvYcCWJJMwp0svyWPz/Xy+XwLKKsytcyy4WsCNJGLWBQaRFfhLh9M/8wunVRJBmrFMsT52IbENo+zCudan+ahF7Aq8EUd3ku2Quna3SUnqe X-Gm-Message-State: AOJu0Yw4q4mIFJ8X7uVtnUIscQrTr9sZ5yB+DJKQRokZWiH6oR014PRQ LCzkF3RQClOU/x6ren8aI5MnlcJlsDAJ8vZuV3ED8sypVWrV/Vs6671SJIlU6TqYsDNdm+h3BEy V35EH5nPWZe5zyqKtwVxMsVde0Gc= X-Google-Smtp-Source: AGHT+IEUg0brb0728/yRBNW9rl066VNioJjnMS2QrZA3dGtQVKXwsiqBC08PvBB1ksqxzzS76yV6ZMKxcEjzyLz5e8s= X-Received: by 2002:a2e:740e:0:b0:2ea:82e4:5812 with SMTP id 38308e7fff4ca-2ea847fc720mr5724951fa.29.1717044517842; Wed, 29 May 2024 21:48:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Peter Smith Date: Thu, 30 May 2024 14:48:11 +1000 Message-ID: Subject: Re: 001_rep_changes.pl fails due to publisher stuck on shutdown To: vignesh C Cc: Alexander Lakhin , 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 Thu, May 30, 2024 at 2:09=E2=80=AFAM vignesh C wro= te: > > On Wed, 29 May 2024 at 16:30, Alexander Lakhin wrot= e: > > > > Hello hackers, > > > > As a recent buildfarm test failure [1] shows: > > [14:33:02.374](0.333s) ok 23 - update works with dropped subscriber col= umn > > ### Stopping node "publisher" using mode fast > > # Running: pg_ctl -D > > /home/bf/bf-build/adder/HEAD/pgsql.build/testrun/subscription/001_rep_c= hanges/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: stat= ement: DELETE FROM tab_rep > > 2024-05-16 14:33:02.925 UTC [2238704][client backend][:0] LOG: disconne= ction: 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 fa= st shutdown request > > 2024-05-16 14:33:03.000 UTC [2222549][postmaster][:0] LOG: aborting an= y active transactions > > 2024-05-16 14:33:03.049 UTC [2222549][postmaster][:0] LOG: background w= orker "logical replication launcher" (PID > > 2223110) exited with exit code 1 > > 2024-05-16 14:33:03.062 UTC [2222901][checkpointer][:0] LOG: shutting d= own > > 2024-05-16 14:39:04.377 UTC [2222549][postmaster][:0] LOG: received im= mediate shutdown request > > 2024-05-16 14:39:04.382 UTC [2222549][postmaster][:0] LOG: database sy= stem 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= exit > > 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 retur= ns > > -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) attac= hed. > > 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. > Hi, FWIW using the provided scripting I was also able to reproduce the problem on HEAD but for me, it was more rare. -- the script passed ok 3 times all 100 iterations; it eventually failed on the 4th run on the 75th iteration. =3D=3D=3D=3D=3D=3D Kind Regards, Peter Smith. Fujitsu Australia