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 1oxwha-00052Q-5N for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Nov 2022 20:50:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oxwhY-0003xl-Sp for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Nov 2022 20:50:36 +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 1oxwhY-0003xb-7h for pgsql-hackers@lists.postgresql.org; Wed, 23 Nov 2022 20:50:36 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oxwhS-0000jA-S0 for pgsql-hackers@postgresql.org; Wed, 23 Nov 2022 20:50:34 +0000 Received: by mail-pg1-x532.google.com with SMTP id 6so17749011pgm.6 for ; Wed, 23 Nov 2022 12:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WJhV2ZHKxOJNnealAK+QwBevMtCS+3YQudM4qvOuBDw=; b=TtC5K7gL0mTOP/GNfgnHqJUwWllV/M7LdaBzzQKwIXCz3XO5GDc/hba1vuRk65MVfQ yHwz4mGxJ+z7gRaRjCty0gEeYFuDoVOaStN6MX+wnnhfEyWG8/k4DtUA59ZPbYlrNfHr Q+Iq4y2wfvIu8v2P5rmolYgAzD7vixyiXRUx+NcQ6knaG76cpvlMSslqTCnXV6CYwGPh 6G9+LEGrxZLmq7ygd3ZMRBoioFbLVwWq7dhq6y8/mJLTFWLe5tQDQpaQkRpnjXbDv9Fb ROw5SP1CRwUDaYpW0Ix/elhNcSKRmwkyjsuEUueqa2dESUNJ9MqBWFBUIkLqfLRUXdV9 XuYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WJhV2ZHKxOJNnealAK+QwBevMtCS+3YQudM4qvOuBDw=; b=3lV8gPMBjEVsRmdV05m3jdAtlalW++q24KjXhlBcDK5I0TuHWvLCUrEXiSsWJwXBeu Qw761n6EQZb1yujeHvMVM0Hcotb3TDutabxZR0DACck5fDoKofeVE13atrOhvKJjSdrF JgTO8hssZtoIG3lE29Y21XuBDavtPs8khMDHP0sy0aGZmgka4smGTsMG0CX27a2F7aFM QtUtfkNoUxq7PlrKf6dIasEL7DyoyfD6DpDEkNG0ouYmW+1KYOaIfWpvzqo0AHYh8lbF F4nEIHAN/mnea3hrvU9oZyRP/zl/sE1f27DIWvNKNZlWL8Lb3IfW26BOfcZqyaRuRNF7 c9YQ== X-Gm-Message-State: ANoB5pnKIIRjqDSXtF9N4GS24m+Tpr17NvMVD5HG09kbS6ju8g0rGuYK cfGbVyk+c6RzoDDA7EpRzUI= X-Google-Smtp-Source: AA0mqf7qyDFwJ0T53SlM0On3/A0eaBPq1pkFtcUhZz7CRIbLXDL1jl7Q7daSU8poZ0sFUauC89aHlA== X-Received: by 2002:a63:647:0:b0:477:c073:cb4b with SMTP id 68-20020a630647000000b00477c073cb4bmr2973172pgg.198.1669236629684; Wed, 23 Nov 2022 12:50:29 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id 10-20020a630a0a000000b00460a5c6304dsm3714143pgk.67.2022.11.23.12.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 12:50:28 -0800 (PST) Date: Wed, 23 Nov 2022 12:50:27 -0800 From: Nathan Bossart To: "houzj.fnst@fujitsu.com" Cc: "Hayato Kuroda (Fujitsu)" , "pgsql-hackers@postgresql.org" Subject: Re: wake up logical workers after ALTER SUBSCRIPTION Message-ID: <20221123205027.GA368966@nathanxps13> References: <20221122004119.GA132961@nathanxps13> <20221122043916.GA230228@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 22, 2022 at 07:25:36AM +0000, houzj.fnst@fujitsu.com wrote: > On Tuesday, November 22, 2022 2:49 PM Hayato Kuroda (Fujitsu) >> Thanks for updating! It becomes better. Further comments: >> >> 01. AlterSubscription() >> >> ``` >> + LogicalRepWorkersWakeupAtCommit(subid); >> + >> ``` >> >> Currently subids will be recorded even if the subscription is not modified. >> I think LogicalRepWorkersWakeupAtCommit() should be called inside the if >> (update_tuple). > > I think an exception would be REFRESH PULLICATION in which case update_tuple is > false, but it seems better to wake up apply worker in this case as well, > because the apply worker is also responsible to start table sync workers for > newly subscribed tables(in process_syncing_tables()). > > Besides, it seems not a must to wake up apply worker for ALTER SKIP TRANSACTION, > Although there might be no harm for waking up in this case. In v3, I moved the call to LogicalRepWorkersWakeupAtCommit() to the end of the function. This should avoid waking up workers in some cases where it's unnecessary (e.g., if ALTER SUBSCRIPTION ERRORs in a subtransaction), but there are still cases where we'll wake up the workers unnecessarily. I think this is unlikely to cause any real problems in practice. >> 02. LogicalRepWorkersWakeupAtCommit() >> >> ``` >> + oldcxt = MemoryContextSwitchTo(TopTransactionContext); >> + on_commit_wakeup_workers_subids = >> lappend_oid(on_commit_wakeup_workers_subids, >> + >> subid); >> ``` >> >> If the subscription is altered twice in the same transaction, the same subid will >> be recorded twice. >> I'm not sure whether it may be caused some issued, but list_member_oid() can >> be used to avoid that. > > +1, list_append_unique_oid might be better. Done in v3. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --LQksG6bCIzRHxTLp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0001-wake-up-logical-workers-after-ALTER-SUBSCRIPTION.patch"