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 1pDOon-0002nL-RL for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Jan 2023 11:53:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pDOom-0000g3-OG for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Jan 2023 11:53: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 1pDOom-0000fs-FK for pgsql-hackers@lists.postgresql.org; Thu, 05 Jan 2023 11:53:56 +0000 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pDOok-0004XW-49 for pgsql-hackers@lists.postgresql.org; Thu, 05 Jan 2023 11:53:55 +0000 Received: by mail-yb1-xb35.google.com with SMTP id 186so39776933ybe.8 for ; Thu, 05 Jan 2023 03:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1s8l5ffLOSk0s4pLHCntbsdTTLoUaD9RQwTxD45lg94=; b=gjTkhy/TjUdCtVn0UztXGX6Hu9q+4s870BkrhwlQl4mvcFsIyt+aie8Di9m2MfzISE Scimt9zcTyiCXF4u8/tqGm+/oSu1EWYUMcx5TUFuhdwk4BcJisV1eWAkiUUdhhPC+yOw is3/JRSTT7PaXIKAtoFKFUvfa9KaCu3Sk7XKGvkIHtq/xYMO/5535Rk4gDe2ZJCNom58 3I/LDb4zVRMX0vNilVV7VuSAuz5U9yEKGfa3NrCfRlYrGjbe5myQMZNhxAKQWHjkDT3s KRWiMHvypMcO4YdhzrCiHxp+9Pj6cBFw9qrjpbBpXja4wcwQhPoUeVr5t4aGn4dJoVoU L0Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=1s8l5ffLOSk0s4pLHCntbsdTTLoUaD9RQwTxD45lg94=; b=iCSkjNjodWYdjb7Q6mDcH4ZAt7+DlVo/tLQFW+pJADAlQOWVSYoodpV7oDj+n863Pw kLTRNYU4iueI2JohzZY1knOMcZDNZqlJ2pEahiAkDLYsjU4u0kyEMQZ1EFtC70zP1fIp lAlL/V9/go6CVGvI9VdO0y1/hik46TqGQlXbj8VyrKA6s82M+BF85NwYRxYV+Ko+63ui PHvd8MjyXN1/XWxvGuo5KJm9Ybgxty86vCfmFLOP8t+VkY05+qIQ/KiFMamK1Goq3IEP hB4wm50gxpzjalAA7iXwdpZ5MYgv2PWRDCwlJlYXY8vyCrgClTcfyFowKiBwbAVjKdsK 029g== X-Gm-Message-State: AFqh2korcNqOsXF6U3K3twZNUe6PPTfDB2JEKjrBioTtA7Eji3HU3GmM MDLYr3hE54TpLEfS74IzcWETm8aq+lhfvEm5Jlo= X-Google-Smtp-Source: AMrXdXvKjpH1Eu8DBgani0Z8ETOjl8nDfYnUPW/oEcAZM9odWO2ynVL3BoD5yggXsYsxN5wzxXkPkCkOpQ0J8Q+jGFE= X-Received: by 2002:a25:3d6:0:b0:73a:4455:b5 with SMTP id 205-20020a2503d6000000b0073a445500b5mr5004454ybd.266.1672919633330; Thu, 05 Jan 2023 03:53:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Dilip Kumar Date: Thu, 5 Jan 2023 17:23:36 +0530 Message-ID: Subject: Re: Perform streaming logical transactions by background workers and parallel apply To: "houzj.fnst@fujitsu.com" Cc: Amit Kapila , Masahiko Sawada , "wangw.fnst@fujitsu.com" , Peter Smith , "shiy.fnst@fujitsu.com" , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 5, 2023 at 5:03 PM houzj.fnst@fujitsu.com wrote: > > On Thursday, January 5, 2023 4:22 PM Dilip Kumar wrote: > > > Thanks for reporting the problem. > > After analyzing the behavior, I think it's a bug on publisher side which > is not directly related to parallel apply. > > I think the root reason is that we didn't try to send a stream end(stream > abort) message to subscriber for the crashed transaction which was streamed > before. > The behavior is that, after restarting, the publisher will start to decode the > transaction that aborted due to crash, and when try to stream the first change > of that transaction, it will send a stream start message but then it realizes > that the transaction was aborted, so it will enter the PG_CATCH block of > ReorderBufferProcessTXN() and call ReorderBufferResetTXN() which send the > stream stop message. And in this case, there would be a parallel apply worker > started on subscriber waiting for stream end message which will never come. I suspected it but didn't analyze this. > I think the same behavior happens for the non-parallel mode which will cause > a stream file left on subscriber and will not be cleaned until the apply worker is > restarted. > To fix it, I think we need to send a stream abort message when we are cleaning > up crashed transaction on publisher(e.g., in ReorderBufferAbortOld()). And here > is a tiny patch which change the same. I have confirmed that the bug is fixed > and all regression tests pass. > > What do you think ? > I will start a new thread and try to write a testcase if possible > after reaching a consensus. I think your analysis looks correct and we can raise this in a new thread. -- Regards, Dilip Kumar EnterpriseDB: http://www.enterprisedb.com