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 1oROEv-0002ML-76 for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Aug 2022 01:34:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oROEt-0004j1-PJ for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Aug 2022 01:34:27 +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 1oROEt-0004is-Et for pgsql-bugs@lists.postgresql.org; Fri, 26 Aug 2022 01:34:27 +0000 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oROEr-0005c6-Gq for pgsql-bugs@lists.postgresql.org; Fri, 26 Aug 2022 01:34:27 +0000 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-3378303138bso1726197b3.9 for ; Thu, 25 Aug 2022 18:34:25 -0700 (PDT) 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; bh=iFmCz5+h709B2t4E0qcxKDQLS2EstG+CyP0dEC5arYc=; b=lzi+2LOmnMGyTDIyxS6GG6z5bM7yhFv+NaouxmoDvMYcfL4Lnw8sINnHf+W9CIpVTJ 4Acm++k3bp/ipyxNnf6GxLKEvygKj8RU9LQqp+zHgG4zU8OBljA/EsDmz/C2d7KGKl1Y 3hysqzX9qawOgL/69SEgDwMidk8uYlVGgGipMUEjVzB4/naTjdEvwe+P5Aa676du6KVy A70nkl8CRXxoY8F2nzthqtzD0oKoNn9ktPBkveuYZ5/3pcmyQBA+n22WvHVb45H3/A+g PrOYSLFWBNxlC6NaWFylpAcucHzm3lkLTY3x3HqL7SO9enyNj21d65RWygFahA/SFnOE PPkg== 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; bh=iFmCz5+h709B2t4E0qcxKDQLS2EstG+CyP0dEC5arYc=; b=xpJWI/xXxhVFPpoTO2aMEYnKHbSfz/43daDO/govsbuXZUlvk3n4lNOsw9PkIhQFTH kJsH5/XK6T2uFJU9ivJNVbpKx36B6sMDIQ7HqXzfha76Fgzm2lbDEbECtcqvyKMbcnk+ T7EFMXfUg7LgirzxrmPNbEtRDBk2makSzQYv9O6o4zxMeSIALuUWPGEKxNj0e/qMjhUq 3Ab2vU7FySCwduqXXqe0llp0UOs7B4IZF3gjdXRXC22aFsptv+cXp+p7YvGlMnCwP/7T kqAXSQWV4DVoZP8972GyMp1zV6NXzQN0Z3FixdCGoHv5MzrIQqCipliBzgdb4xzDIqMU sf6Q== X-Gm-Message-State: ACgBeo0vwt4prYbagOiBtXgZqdcK1TKf371/xB+yLdc+Y9CZbDgwEfBl 7rPOr6lGoOju2BQXn5RidBjH1gs8UzZWHBHGWtA= X-Google-Smtp-Source: AA6agR4mTATI7sbO+A6F8TERATtllh07uTqr182+PIQbELPGNLuZoj9Y0fAT3RK7j0QIb8q5gHWUPPGwoDJiUEtirU0= X-Received: by 2002:a81:5716:0:b0:335:41fc:feea with SMTP id l22-20020a815716000000b0033541fcfeeamr6540759ywb.305.1661477663769; Thu, 25 Aug 2022 18:34:23 -0700 (PDT) MIME-Version: 1.0 References: <20220714115155.GA5439@depesz.com> <20220718094330.GA24063@depesz.com> In-Reply-To: From: Amit Kapila Date: Fri, 26 Aug 2022 07:04:12 +0530 Message-ID: Subject: Re: Excessive number of replication slots for 12->14 logical replication To: Ajin Cherian Cc: Masahiko Sawada , Peter Smith , "houzj.fnst@fujitsu.com" , Hubert Lubaczewski , PostgreSQL mailing lists 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, Aug 25, 2022 at 7:38 PM Ajin Cherian wrote: > > On Wed, Aug 24, 2022 at 3:54 PM Amit Kapila wrote: > > > > On Tue, Aug 23, 2022 at 7:56 PM Amit Kapila wrote: > > > > > > On Thu, Aug 18, 2022 at 11:28 AM Ajin Cherian wrote: > > > > > > > > On Thu, Aug 18, 2022 at 3:46 PM Masahiko Sawada wrote: > > > > > Looks good. > > > > > > > > > > I have one minor comment: > > > > > > > > > > - * SUBREL_STATE_FINISHEDCOPY. The apply worker can also > > > > > - * concurrently try to drop the origin and by this time > > > > > - * the origin might be already removed. For these reasons, > > > > > - * passing missing_ok = true. > > > > > + * SUBREL_STATE_FINISHEDCOPY. So passing missing_ok = true. > > > > > > > > > > I think we should change "the apply worker" to "the tablesync worker" > > > > > but should not remove this sentence. The fact that another process > > > > > could concurrently try to drop the origin is still true. > > > > > > > > > > The rest looks good to me. > > > > > > > > > > > > > Updated as described. > > > > > > > > > > The patch looks good to me though I would like to test it a bit more > > > before pushing. > > > > > > > While testing/reviewing it further, I noticed that the patch has used > > missing_ok as true when dropping origin via tablesync worker. I don't > > think that is correct because the concurrent operations that remove > > origin like a refresh for the subscription take an access exclusive > > lock on pg_subscription which prevent the previous operation to update > > the rel state to SUBREL_STATE_SYNCDONE to succeed. So, I think we > > should pass missing_ok as false which would be consistent with slot > > handling. I have changed that and comments a few places. What do you > > think of the attached? > > > > Yes, this makes sense. I tested with a debugger to create simultaneous > alter subscription refresh publication AND tablesync worker > deleting the tracking origin. What I see is that the alter subscription command > gets the lock on SubscriptionRelRelationId and then actually goes on to > kill the tablesync worker. Even if the tablesync worker is waiting for > the same lock, > it looks like the SIGTERM is being handled and the worker is killed. > > From my testing, there doesn't seem to be a case where the tablesync worker > would try and drop a previously dropped origin. So, I think we can pass > missing_ok as 'false' while dropping origin. The patch looks good to me. > Thanks for the testing. I'll push this sometime early next week (by Tuesday) unless Sawada-San or someone else has any comments on it. -- With Regards, Amit Kapila.