Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMU4j-0003hx-N6 for pgsql-general@arkaria.postgresql.org; Mon, 30 Jan 2023 13:19:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pMU4i-0004c6-FX for pgsql-general@arkaria.postgresql.org; Mon, 30 Jan 2023 13:19:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pMU4i-0004bx-0t for pgsql-general@lists.postgresql.org; Mon, 30 Jan 2023 13:19:56 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pMU4f-0001ir-2e for pgsql-general@lists.postgresql.org; Mon, 30 Jan 2023 13:19:55 +0000 Received: by mail-ed1-x531.google.com with SMTP id cw4so5771696edb.13 for ; Mon, 30 Jan 2023 05:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=6wK0BaUGePjk8848eSxBf4YpP5AfEDH2hr2gw2lJU9E=; b=Lu8TzRDojvQMZBzLW69W+LljcxOyNi9gy1dgdTfWLulPcHVjPqItVpvTuxcuVKrbzN MiBN5pS3GIjgBwVhdmNue38mfVu7o5ix1A7c407udPAq03f+9bTM5Mo8caSLAjTHRZ2p 1ZT97dxPqekc0OrYi+HmknMPq7wwFxglWtKVJX/uD8uF+9II6kqpI79Nu7h/SNERUmqb cY7DWMATKUfjkCbRsC4Iu1YNQIWDREEAzfVc2oAkHq98KO7biDTpBnjXiZJxNlu9NnUG rMfSKIXLP1KfIhOtNqnAxZJ5XP6AkvlprDv62kb/Y1j2gQN2d4w+bRSP6yRXg2KMsb80 5Mnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6wK0BaUGePjk8848eSxBf4YpP5AfEDH2hr2gw2lJU9E=; b=5Jdz0j444xcpzALR4ezs6pGmhWRxrydgYhYW7cYAgAadUUWvTNtTMU3ZOypxjWY0l6 DEs/5SF8OC6YCuCaxlNZctyGH15o6yX7Y5ZtSk0YbRab+e+qc0QKZvKX6TxuVOKnnd5w 0+eASSL0HWyIlbex3N77Lcaq4J4KnqwIjRwIkvkBEbSGQW7OBy6iqFQ291f/lxzqSR8a m8/snJoYs56jAi8ld1iF/9qIknFj+pFrn4eSva9vBjklQPGfLMP4MyodESu3T9j5yzUt 0BEce+ixpRmXZboBszPvLm/LW/05/AKrxpZn4pPGIVbGonZRQHZaJzUSYQ8W7uVoqe8u rxSA== X-Gm-Message-State: AFqh2koaagNB5qfW55z+Pd4IJ/zsLIKDQXb/6xg6pUht24sycr7ifS4Q XZMtpZ3du3RViuCtkRoxu8wG3w== X-Google-Smtp-Source: AMrXdXvGffD7UbdeovknsAiMJa6zTCKw7qPHF+R00OwOeiSHjHbhGYe2ixWZ3DVKTzf/NyI2lf2gLg== X-Received: by 2002:a05:6402:2405:b0:49d:1a59:176b with SMTP id t5-20020a056402240500b0049d1a59176bmr59599128eda.30.1675084791612; Mon, 30 Jan 2023 05:19:51 -0800 (PST) Received: from dynamic-pd01.res.v6.highway.a1.net ([2001:871:5e:539:1b2c:c52a:475d:310c]) by smtp.gmail.com with ESMTPSA id s21-20020a05640217d500b0046267f8150csm1933429edy.19.2023.01.30.05.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 05:19:51 -0800 (PST) Message-ID: <84018b9c65559d57c854538f2a131edd4ab3d40d.camel@cybertec.at> Subject: Re: Does statement_timeout apply to commit? From: Laurenz Albe To: qihua wu , pgsql-general@lists.postgresql.org Date: Mon, 30 Jan 2023 14:19:50 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.3 (3.46.3-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-01-30 at 17:10 +0800, qihua wu wrote: > I have a patroni cluster running in sync mode and at least 2 nodes should= be > synced for commit. Now I brought down one node, so only one slave is in s= ync, > and then write a java program to write the data to primary in autocommit = =3D false > mode, I set statement_timeout to 10, hopping the jave will throw exceptio= n > after 10 seconds after I send a commit command to postgresq, but after 10= seconds, > it didn't throw any exception, so looks like statement_timeout doesn't ap= ply to > commit. Is that theory right?. I assume you are talking about synchronous replication. static void CommitTransaction(void) { [...] /* Prevent cancel/die interrupt while cleaning up */ HOLD_INTERRUPTS(); [...] if (!is_parallel_worker) { /* * We need to mark our XIDs as committed in pg_xact. This is where= we * durably commit. */ latestXid =3D RecordTransactionCommit(); } [...] RESUME_INTERRUPTS(); } static TransactionId RecordTransactionCommit(void) { [...] /* * Wait for synchronous replication, if required. Similar to the decisi= on * above about using committing asynchronously we only want to wait if * this backend assigned an xid and wrote WAL. No need to wait if an x= id * was assigned due to temporary/unlogged tables or due to HOT pruning. * * Note that at this stage we have marked clog, but still show as runni= ng * in the procarray and continue to hold locks. */ if (wrote_xlog && markXidCommitted) SyncRepWaitForLSN(XactLastRecEnd, true); [...] } So yes, it looks like you are right. Yours, Laurenz Albe