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 1nVG9O-0002Bn-7H for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Mar 2022 17:12:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nVG9N-0007nq-3e for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Mar 2022 17:12:29 +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 1nVG9M-0007nh-DL for pgsql-hackers@lists.postgresql.org; Fri, 18 Mar 2022 17:12:28 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nVG9I-0006zT-2H for pgsql-hackers@postgresql.org; Fri, 18 Mar 2022 17:12:27 +0000 Received: by mail-lf1-x12d.google.com with SMTP id a25so1716852lfm.10 for ; Fri, 18 Mar 2022 10:12:23 -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 :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=BTef1b8QguxeY23fg725MWMhkRbdIvmnmI3DSnE1iNI=; b=YOSmSazQAOXpEP4KVxfRf5AqJMJ1CxMGNZ9rqEDL3jwMpHxYDeMgvU6uTpbRZEcvfs U1zuuTX+UzoJILKvfg7Z/v+hr5YFQLL1HwJZGt2WDk8Mbv6PH7i5AsTAJuspEoX+Wirv FCqu8mqVPSOcH+JrEU6vdgIM+HzrqXS+HXfUqTEK3GimlQTVEZAa+m3XTfrT/oLIbC+n Ry5afe4Sn3ycoNPi9+OJAFH55puKzTWn9Qq5TY6Ar6Wnhbxb7gMAM/pZlcp918uxQ+R0 SuDh7I7mLRdPVBZTru4519SQdoDEVhGRLpo9KmKBoUxWDPuwYGtzP8u7Fyrot1Xzi9a4 lnDg== 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:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=BTef1b8QguxeY23fg725MWMhkRbdIvmnmI3DSnE1iNI=; b=japYiUzIbgJBT4tFYmHOQT/xlquatSFMnDgjYb9UjI8MlvAXKim81ldlENLF9uLgbR K3MNs/ClcarZnq4O3vkOtKpKBHZxOK119HQbyaiq7CjMIwosTyjTNfWCLx8OEChu1lD9 dKcOwHV5ieHQGMjsvQVyGuzvSmzoj31syprzwRyp3A3BvWLPS7k4Yzb5mxW6cFJcCvwT TlFo8+4J42PKE5ec4FLptlfJdtvbdnzIFqYq0E5bJmXJbDzQhssIc3IK74y3BR/aZTtT 1a0OG9gSi5tk/kPgrb4iRn3Q54xNiLCMKk6srNOmoBFDQsxWGpFDR3hvncrKzV7YM9ao 2QcA== X-Gm-Message-State: AOAM532V7YWq1FZEWY/Sa3L7e8+bWx3qc+27VH6z6swskGe0KgSGUhPw 64LAEkktk8iFhdbP/YN8yofifQBXx+XOzzQhoIBj4NXYXCe11uPOX+yPYy3GVokAq2598vcar0O VgsKo4gJqizzndaY6UFsn3a3dnC2viNa61QEJQBpX7doB9fHNxRXCYMAn2ZfhL/tnNa0455j8mh yCxnDBz2ZCn3yXQnj98PoTq6Itv/B8T9OvV8lO X-Google-Smtp-Source: ABdhPJx+nS1VoCqwB2PyEHhpX2010CKnC4LiSL12UWuQgQhYYJzJEQFjguHnUZP1onqCg5iOeCmKNA== X-Received: by 2002:ac2:5dd4:0:b0:448:b3ea:9171 with SMTP id x20-20020ac25dd4000000b00448b3ea9171mr6690610lfq.234.1647623542494; Fri, 18 Mar 2022 10:12:22 -0700 (PDT) Received: from [10.137.0.17] (37-247-27-82.customers.ownit.se. [37.247.27.82]) by smtp.gmail.com with ESMTPSA id x14-20020a056512078e00b004481e3198cesm930428lfr.142.2022.03.18.10.12.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Mar 2022 10:12:21 -0700 (PDT) Message-ID: <369ae611-8822-f499-87cd-58ad0d60c60c@enterprisedb.com> Date: Fri, 18 Mar 2022 18:12:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: Column Filtering in Logical Replication Content-Language: en-US From: Tomas Vondra To: Amit Kapila 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> <78b8d385-57cb-9a3f-cfe5-9f300f15eced@enterprisedb.com> <822a8e40-287c-59ff-0ea9-35eb759f4fe6@enterprisedb.com> <2b8471f9-3849-c91f-ef82-9181d4bca0a7@enterprisedb.com> <16e83ce3-8415-b732-37b2-c3329a2c13a1@enterprisedb.com> <3162f7f0-86ac-e3a9-dc55-0a660cb9bab1@enterprisedb.com> In-Reply-To: <3162f7f0-86ac-e3a9-dc55-0a660cb9bab1@enterprisedb.com> 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 3/18/22 15:43, Tomas Vondra wrote: > > > On 3/18/22 06:52, Amit Kapila wrote: >> On Fri, Mar 18, 2022 at 12:47 AM Tomas Vondra >> wrote: >>> >>> I pushed the second fix. Interestingly enough, wrasse failed in the >>> 013_partition test. I don't see how that could be caused by this >>> particular commit, though - see the pgsql-committers thread [1]. >>> >> >> I have a theory about what's going on here. I think this is due to a >> test added in your previous commit c91f71b9dc. The newly added test >> added hangs in tablesync because there was no apply worker to set the >> state to SUBREL_STATE_CATCHUP which blocked tablesync workers from >> proceeding. >> >> See below logs from pogona [1]. >> 2022-03-18 01:33:15.190 CET [2551176][client >> backend][3/74:0][013_partition.pl] LOG: statement: ALTER SUBSCRIPTION >> sub2 SET PUBLICATION pub_lower_level, pub_all >> 2022-03-18 01:33:15.354 CET [2551193][logical replication >> worker][4/57:0][] LOG: logical replication apply worker for >> subscription "sub2" has started >> 2022-03-18 01:33:15.605 CET [2551176][client >> backend][:0][013_partition.pl] LOG: disconnection: session time: >> 0:00:00.415 user=bf database=postgres host=[local] >> 2022-03-18 01:33:15.607 CET [2551209][logical replication >> worker][3/76:0][] LOG: logical replication table synchronization >> worker for subscription "sub2", table "tab4_1" has started >> 2022-03-18 01:33:15.609 CET [2551211][logical replication >> worker][5/11:0][] LOG: logical replication table synchronization >> worker for subscription "sub2", table "tab3" has started >> 2022-03-18 01:33:15.617 CET [2551193][logical replication >> worker][4/62:0][] LOG: logical replication apply worker for >> subscription "sub2" will restart because of a parameter change >> >> You will notice that the apply worker is never restarted after a >> parameter change. The reason was that the particular subscription >> reaches the limit of max_sync_workers_per_subscription after which we >> don't allow to restart the apply worker. I think you might want to >> increase the values of >> max_sync_workers_per_subscription/max_logical_replication_workers to >> make it work. >> > > Hmmm. So the theory is that in most runs we manage to sync the tables > faster than starting the workers, so we don't hit the limit. But on some > machines the sync worker takes a bit longer, we hit the limit. Seems > possible, yes. Unfortunately we don't seem to log anything when we hit > the limit, so hard to say for sure :-( I suggest we add a WARNING > message to logicalrep_worker_launch or something. Not just because of > this test, it seems useful in general. > > However, how come we don't retry the sync? Surely we don't just give up > forever, that'd be a pretty annoying behavior. Presumably we just end up > sleeping for a long time before restarting the sync worker, somewhere. > I tried lowering the max_sync_workers_per_subscription to 1 and making the workers to run for a couple seconds (doing some CPU intensive stuff), but everything still works just fine. Looking a bit closer at the logs (from pogona and other), I doubt this is about hitting the max_sync_workers_per_subscription limit. Notice we start two sync workers, but neither of them ever completes. So we never update the sync status or start syncing the remaining tables. So the question is why those two sync workers never complete - I guess there's some sort of lock wait (deadlock?) or infinite loop. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company