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 1p2Six-0005Ue-5D for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 07:50:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2Siu-0002lP-AU for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 07:50:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2Sit-0002lF-VM for pgsql-hackers@lists.postgresql.org; Tue, 06 Dec 2022 07:50:40 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2Sir-0005sr-SQ for pgsql-hackers@lists.postgresql.org; Tue, 06 Dec 2022 07:50:39 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-3e78d07ab4fso73088037b3.9 for ; Mon, 05 Dec 2022 23:50:37 -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=K7BAd6WnlFcorQGkOlIb1I4H/6+fir30E9nbysmY00s=; b=otqT7ythsaSgHMqVbmyUcXUrn+fpPJskfPk3trR0MeP/ubpo58SZQ2ABZezTVA5dmy 4iCquTsoT4sCfe1oJEs0zXcLZEyWqPKhuquKz4jSenyEsorL2vmO0hCXQ0qfe2s9BE45 ZY4JV/ZoUsnAlWGvqhV6NGNTVUoiuupGXffPt0b75YfGQEZ9K9BI+4arwzEGulpizUXO H4nDSM0o+FN2t+/wklYPEK3MqD/lO0ruDuXduFYoADZATOT7tHCe0ygxrA5vaB6i4vUD zSunW9n2R5LGgg05DSWp3r594CO5XKFQHxHZ2ETnznLgZH2TGMw1sIy2EPcHnnXH3HrB AWWg== 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=K7BAd6WnlFcorQGkOlIb1I4H/6+fir30E9nbysmY00s=; b=A4tnfP65Bot6ZMooL9/vKu2ehuZJ5n6XAPpnlHXGHbex3Kp2IGeRrQOVUxrOip1VRf omvPtF3ZnsJbi+me1mTVFMDuAs+rd3i6SgxoULyLblEA9afcLfFNrVJtcQ775P+f9v3B gA9wp9PuK0emtYKnjt3dlAcdjYyJhVScMc3/uYr7dNFbG6jPQYXwOmi/vBelW4deb1aU Dlp91IfzBJ4jGq94nCEmzIW1PZthUjUO+FJS5pu0fkSGNfEX+iQXmI9OptL36GV+9fuu VoO88jWZCfpNNmVo9DG7iUikXAF+SXE5/TsUu+LqaE5oOG1g/VduA5I+GNyvL7f/nRxn +8jA== X-Gm-Message-State: ANoB5pmUgtqLWYpaYl3yPEP3wi+xB3EdL4cUL3qGzeQiMviCVG+zxhR+ KE85ejEVGBNagr7T0CD75bBocgJ4QjIZRHtEImU= X-Google-Smtp-Source: AA0mqf5E2VJn8Buh5zr5Oc/e02Kph/ebjE1JfBImWBnNEV8vuSwoTfC/nfKWQfoKi5H2CDKa70sjEFA+4YeqbNGYSGg= X-Received: by 2002:a81:194f:0:b0:3de:7599:c5fd with SMTP id 76-20020a81194f000000b003de7599c5fdmr18874259ywz.84.1670313035759; Mon, 05 Dec 2022 23:50:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Amit Kapila Date: Tue, 6 Dec 2022 13:20:24 +0530 Message-ID: Subject: Re: Perform streaming logical transactions by background workers and parallel apply To: "houzj.fnst@fujitsu.com" Cc: Masahiko Sawada , "wangw.fnst@fujitsu.com" , Peter Smith , Dilip Kumar , "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 Mon, Dec 5, 2022 at 9:59 AM houzj.fnst@fujitsu.com wrote: > > Attach a new version patch set which fixed a testcase failure on CFbot. > Few comments: ============ 1. + /* + * Break the loop if the parallel apply worker has finished applying + * the transaction. The parallel apply worker should have closed the + * file before committing. + */ + if (am_parallel_apply_worker() && + MyParallelShared->xact_state == PARALLEL_TRANS_FINISHED) + goto done; This looks hackish to me because ideally, this API should exit after reading and applying all the messages in the spool file. This check is primarily based on the knowledge that once we reach some state, the file won't have more data. I think it would be better to explicitly ensure the same. 2. + /* + * No need to output the DEBUG message here in the parallel apply + * worker as similar messages will be output when handling STREAM_STOP + * message. + */ + if (!am_parallel_apply_worker() && nchanges % 1000 == 0) elog(DEBUG1, "replayed %d changes from file \"%s\"", nchanges, path); } I think this check appeared a bit ugly to me. I think it is okay to get a similar DEBUG message at another place (on stream_stop) because (a) this is logged every 1000 messages whereas stream_stop can be after many more messages, so there doesn't appear to be a direct correlation; (b) due to this, we can identify whether it is due to spooled messages or due to direct apply; ideally we can use another DEBUG message to differentiate but this doesn't appear bad to me. 3. The function names for serialize_stream_start(), serialize_stream_stop(), and serialize_stream_abort() don't seem to match the functionality they provide because none of these write/serialize changes to the file. Can we rename these? Some possible options could be stream_start_internal or stream_start_guts. -- With Regards, Amit Kapila.