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 1ngQc3-00084N-Jm for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Apr 2022 12:36:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ngQc2-00025D-3y for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Apr 2022 12:36:14 +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 1ngQc1-000253-9Y for pgsql-hackers@lists.postgresql.org; Mon, 18 Apr 2022 12:36:13 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ngQbv-0004LS-Hr for pgsql-hackers@postgresql.org; Mon, 18 Apr 2022 12:36:11 +0000 Received: by mail-ej1-x62c.google.com with SMTP id u15so26550757ejf.11 for ; Mon, 18 Apr 2022 05:36:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=CGyt19l4Jp7nhpS+14KLS8yb3WYHxWELUsv90NgRsNc=; b=PFAGSOFTKU6rUeboC8cZpt5VrNw7T7ORlOKdBtJkqZotxqsLYk9UCZWiOFhh+OblCq UZdmaiYIbwywRBvnyKVkuHtDXNkl/Uvrdlf7DLYhAHClTouHqWoTkzNZFY0OWZef9tIo DlNBWsDvHkRSFUwuTBqIZyyv1d7nLvr1xYP70PkfHB6eSOvtiS6cIlclRlUreFAt59tY 4x9Tk1R/xRT0vWxnyZmD9UwRI0VNCrNX6WGIN+PQCXLV1ePYhKkBqMhg63LNatsjvYpV yftdrA5zP2/3UkkiZn6PQATpXrI1MwFHgxEjBun8VF45738G2RO4IPWdFTt31rUZhdew /1Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=CGyt19l4Jp7nhpS+14KLS8yb3WYHxWELUsv90NgRsNc=; b=FgoN8toSPH/3Z7ChWK/HdTv2WDTAuW7YaciUhnkfTubxBhaHZN4N2jtaHLJ7nj8ydZ msmLaIyhbNaN0inwrFlemsxnx4J8AqADfhMBTC140Cr0wjPpHA7VKXBHZzSXIkOV2uR2 QJtIYz7vllYOmfSkqWav5F+051/83AMt3WG0t+XBZAaqEmoQyfPVGG1B9DfwPklfz7Dp ZLw83qbd5QUVIxraA8kRi6Y8wBsElssslYRjpsTh5A2ZzMFMY+FWDwoL8mqiLQ66u5l4 LZAjUUaVJjH+PAL2tlwrKjs/Q0xywZ05Cx0OziK8kSiPEPMlj/TwZ5IjpxwK98KdCs1C WdNg== X-Gm-Message-State: AOAM530g2rrKTXBq9lOxIA+0zo0o/wFpW1vUZka+2jhY/RAhf6R8R3kv 6IsHpSagM7ysyyyJawIUEbWSETAWqBzyyA7C8UwZS9VX7rFu6xPNBnJ62WoeOCKqebp8tkQvC3O UDZUkAsVoTzyo0RaVTTYGmVILsDQlTslrJcVqq1eDBxFm4kGEmYUesXxlmLis0GMId5vIntyESK 2MIpfS/pLcsKVo7RFFW4XlamuA5/gQpgEmxdOq X-Google-Smtp-Source: ABdhPJwqGtK0xljVSsdSS8cBrZqn3M8FRC0C/7tvC4UEZfMBO7TP7r5VHz+G5V7WFUl50PkgfclkZQ== X-Received: by 2002:a17:907:2cc3:b0:6da:e6cb:2efa with SMTP id hg3-20020a1709072cc300b006dae6cb2efamr8751819ejc.169.1650285365973; Mon, 18 Apr 2022 05:36:05 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-250-165.net.upcbroadband.cz. [86.49.250.165]) by smtp.gmail.com with ESMTPSA id s2-20020a1709066c8200b006e4e1b1f875sm4575841ejr.199.2022.04.18.05.36.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 05:36:03 -0700 (PDT) Message-ID: Date: Mon, 18 Apr 2022 14:36:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101 Thunderbird/100.0 Subject: Re: Column Filtering in Logical Replication Content-Language: en-US To: Amit Kapila , Masahiko Sawada , Petr Jelinek Cc: "houzj.fnst@fujitsu.com" , Peter Eisentraut , Alvaro Herrera , Justin Pryzby , Rahila Syed , Peter Smith , pgsql-hackers , "shiy.fnst@fujitsu.com" References: <202201120041.p24wvsfcsope@alvherre.pgsql> <3162f7f0-86ac-e3a9-dc55-0a660cb9bab1@enterprisedb.com> <369ae611-8822-f499-87cd-58ad0d60c60c@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/18/22 13:04, Amit Kapila wrote: > On Thu, Apr 14, 2022 at 9:09 AM Amit Kapila wrote: >> >> On Thu, Apr 14, 2022 at 8:32 AM Masahiko Sawada wrote: >>>> >>>> The other part of the puzzle is the below check in the code: >>>> /* >>>> * If we reached the sync worker limit per subscription, just exit >>>> * silently as we might get here because of an otherwise harmless race >>>> * condition. >>>> */ >>>> if (nsyncworkers >= max_sync_workers_per_subscription) >>>> >>>> It is not clear to me why this check is there, if this wouldn't be >>>> there, the user would have got either a WARNING to increase the >>>> max_logical_replication_workers or the apply worker would have been >>>> restarted. Do you have any idea about this? >>> >>> Yeah, I'm also puzzled with this check. It seems that this function >>> doesn't work well when the apply worker is not running and some >>> tablesync workers are running. I initially thought that the apply >>> worker calls to this function as many as tables that needs to be >>> synced, but it checks the max_sync_workers_per_subscription limit >>> before calling to logicalrep_worker_launch(). So I'm not really sure >>> we need this check. >>> >> >> I just hope that the original author Petr J. responds to this point. I >> have added him to this email. This will help us to find the best >> solution for this problem. >> > > I did some more investigation for this code. It is added by commit [1] > and the patch that led to this commit is first time posted on -hackers > in email [2]. Now, neither the commit message nor the patch (comments) > gives much idea as to why this part of code is added but I think there > is some hint in the email [2]. In particular, read the paragraph in > the email [2] that has the lines: ".... and limiting sync workers per > subscription theoretically wasn't either (although I don't think it > could happen in practice).". > > It seems that this check has been added to theoretically limit the > sync workers even though that can't happen because apply worker > ensures that before trying to launch the sync worker. Does this theory > make sense to me? If so, I think we can change the check as: "if > (OidIsValid(relid) && nsyncworkers >= > max_sync_workers_per_subscription)" in launcher.c. This will serve the > purpose of the original code and will solve the issue being discussed > here. I think we can even backpatch this. What do you think? > Sounds reasonable to me. It's unfortunate there's no explanation of what exactly is the commit message fixing (and why), but I doubt anyone will remember the details after 5 years. +1 to backpatching, I consider this to be a bug regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company