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 1pGCrE-0005xB-6o for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Jan 2023 05:44:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pGCrC-00089u-Um for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Jan 2023 05:44:02 +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 1pGCrC-00089l-Is for pgsql-hackers@lists.postgresql.org; Fri, 13 Jan 2023 05:44:02 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pGCr8-00012n-F6 for pgsql-hackers@lists.postgresql.org; Fri, 13 Jan 2023 05:44:01 +0000 Received: by mail-oi1-x22a.google.com with SMTP id o66so16992590oia.6 for ; Thu, 12 Jan 2023 21:43:58 -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=nrzjvUAGlN32vzuDk1Jjagy/ZIUdJu981QmbrsCtY1M=; b=Nt5zDwqzsXkyNnpYvzadsgS1+uR8Rl/w5mVGDV2Tz7o745d6x6qT0TsxhjRgQBr9kt OxjVYqsOC4gS+SgHZiYkbDyHpxrOGH50b1GVvJdAryNpJMvvffHm5UDdx5kSYbH9TqAA 69NCTTgS1vJXtixVOBgKwAZ6l3pKpzP0yoH8ytI++fgfMPBGvrBmiqdOhLIxlt//2UxH e/nR/8e8XW/ue3mbmnxDazvwtx7Cz/8Ohq2WYsZu1WrF3Uokk8OOtweuS1sjEaA5qKjI tWEP9vmmxUZHl/YQY9GW/1bLZGukz3D4pIcjzk3lYZ5/wG/D1yMrsOPoBOqWw0B6zYbx Sotg== 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=nrzjvUAGlN32vzuDk1Jjagy/ZIUdJu981QmbrsCtY1M=; b=t4q3drwaXqsT/XctK8iMFuhoI4D0sVPVoe7DgqzLwbD+NjsB2LabSm74IFnOmPm4Rt Z3v46Y6F5Qj3hLuBS3eQH6/O6JS451xuOUgHuJTu+V8Yf2wfujNQSz0ytFN3V9xA/KXK HpvtyE91PT05Q59g4Zg/pAKtrVWrcvd4GoLl+Y6eRrxF7jnepv3alh0ZmW0v5neNjeEb xku2HEGngmVl9/gACKBVAYUDWyb9zkAFg/iYFQU2+Amgbhzkqf2m7bXoD1QH0LRKT7Ro wI1PIyTHchTl6F5iwEa6T3OYKUcqT+DEweXZtWsc8G5+eTIh0cq/8yS7POkNZp5/R4Xj FEnA== X-Gm-Message-State: AFqh2kr3NDlryoo1m+l+9eSOLVx+lLvz51ZZIJexC/m4S/zm8vgEtDOQ y2iRowOWrVVcpCC3kSuUZVvnqzt1+fCTS50OwGk= X-Google-Smtp-Source: AMrXdXtIRWRoJCGyD71z+q4oB8yqAQixqcElpV7pdvZTHFusfHYIdPtLmlRipnW8tUFXSSSXAXZFs4c1b2olq0CvZSs= X-Received: by 2002:aca:3745:0:b0:363:b512:25ce with SMTP id e66-20020aca3745000000b00363b51225cemr3184738oia.64.1673588637651; Thu, 12 Jan 2023 21:43:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Fri, 13 Jan 2023 14:43:21 +0900 Message-ID: Subject: Re: Perform streaming logical transactions by background workers and parallel apply To: "houzj.fnst@fujitsu.com" Cc: Amit Kapila , shveta malik , Peter Smith , "wangw.fnst@fujitsu.com" , "shiy.fnst@fujitsu.com" , PostgreSQL Hackers , Dilip Kumar 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 12, 2023 at 9:34 PM houzj.fnst@fujitsu.com wrote: > > On Thursday, January 12, 2023 7:08 PM Amit Kapila wrote: > > > > On Thu, Jan 12, 2023 at 4:21 PM shveta malik wrote: > > > > > > On Thu, Jan 12, 2023 at 10:34 AM Amit Kapila > > wrote: > > > > > > > > On Thu, Jan 12, 2023 at 9:54 AM Peter Smith > > wrote: > > > > > > > > > > > > > > > doc/src/sgml/monitoring.sgml > > > > > > > > > > 5. pg_stat_subscription > > > > > > > > > > @@ -3198,11 +3198,22 @@ SELECT pid, wait_event_type, wait_event > > > > > FROM pg_stat_activity WHERE wait_event i > > > > > > > > > > > > > > > > > > > role="column_definition"> > > > > > + apply_leader_pid > > integer > > > > > + > > > > > + > > > > > + Process ID of the leader apply worker, if this process is a apply > > > > > + parallel worker. NULL if this process is a leader apply worker or a > > > > > + synchronization worker. > > > > > + > > > > > + > > > > > + > > > > > + > > > > > + > > > > + role="column_definition"> > > > > > relid oid > > > > > > > > > > > > > > > OID of the relation that the worker is synchronizing; null for the > > > > > - main apply worker > > > > > + main apply worker and the parallel apply worker > > > > > > > > > > > > > > > > > > > > 5a. > > > > > > > > > > (Same as general comment #1 about terminology) > > > > > > > > > > "apply_leader_pid" --> "leader_apply_pid" > > > > > > > > > > > > > How about naming this as just leader_pid? I think it could be > > > > helpful in the future if we decide to parallelize initial sync (aka > > > > parallel > > > > copy) because then we could use this for the leader PID of parallel > > > > sync workers as well. > > > > > > > > -- > > > > > > I still prefer leader_apply_pid. > > > leader_pid does not tell which 'operation' it belongs to. 'apply' > > > gives the clarity that it is apply related process. > > > > > > > But then do you suggest that tomorrow if we allow parallel sync workers then > > we have a separate column leader_sync_pid? I think that doesn't sound like a > > good idea and moreover one can refer to docs for clarification. > > I agree that leader_pid would be better not only for future parallel copy sync feature, > but also it's more consistent with the leader_pid column in pg_stat_activity. > > And here is the version patch which addressed Peter's comments and renamed all > the related stuff to leader_pid. Here are two comments on v79-0003 patch. + /* Force to serialize messages if stream_serialize_threshold is reached. */ + if (stream_serialize_threshold != -1 && + (stream_serialize_threshold == 0 || + stream_serialize_threshold < parallel_stream_nchunks)) + { + parallel_stream_nchunks = 0; + return false; + } I think it would be better if we show the log message ""logical replication apply worker will serialize the remaining changes of remote transaction %u to a file" even in stream_serialize_threshold case. IIUC parallel_stream_nchunks won't be reset if pa_send_data() failed due to the timeout. Regards, -- Masahiko Sawada Amazon Web Services: https://aws.amazon.com