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 1pJuJx-0003uF-Gz for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Jan 2023 10:45:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pJuJw-0005ES-EB for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Jan 2023 10:45:00 +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 1pJuJw-0005EI-3J for pgsql-hackers@lists.postgresql.org; Mon, 23 Jan 2023 10:45:00 +0000 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pJuJt-0000aE-4B for pgsql-hackers@postgresql.org; Mon, 23 Jan 2023 10:44:59 +0000 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-15f97c478a8so13380212fac.13 for ; Mon, 23 Jan 2023 02:44:57 -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=t18l1L9xtKSbPdfBrzqAYvxstoHCWvWIQsHw834whrU=; b=j4zfJyKke9++VQy24H6dwe3dB2WTSXDcHglkJ/4XJ1xdmbk2GDgkqqew3LIN0mi6Cf kormPJbe4X/5/fhfqFL/uNyUnfxnpUO1O2uR+hDGmClxlUGlzxxCugYACjsdN0D490DO REjXIF9OiXqAmv5dgm+zDIhlrSRubFNRHNyuFpmgXqGKOn1iJ9kNdGkFBrgRAL1qonWF Q3RKRslAOVbN3/a2PPpaDSWvInJgJqe5B4UdABtYg5WrIOK+24/I+K26jEa7CyO7yjtd emg+lNRArXtJMqrW3jS9ZRHvASI7Yq0gx1Z0eHc/cQII/AA1cxjnEKr/fwHdV98qZfGz HzNg== 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=t18l1L9xtKSbPdfBrzqAYvxstoHCWvWIQsHw834whrU=; b=sGLx6jXyqj6rTs0WAItLaRM3kMI0JVusP08tnZqHf9qNo0xnLpbzqrQCEaRWivIkYg JhiFJSCW8/r25dk56saWUulpVgmC3xK7S3yJwknndkvJoySQZuD+dtiL6eBtTK8OSKbe 4crX0E3eohNzREQ8gDeXEwAJ+8tXNXAqm/n8XpbnDkWnN7CQA3TSS9tymhz9l/+SOGJU as9tust6WuMiiispeD6bTRYrfB4wxxIpW1JTuSaq5oHkiknyafi+2dosfLNHvRBDI9te OPBJxOb0hBtMVT9CWdHX/19jPsOgYqGpoGDFKB/0OZ5VH5GI15h+o45nGwp+Y8rmg6g4 f2iw== X-Gm-Message-State: AFqh2kr7ZCKdM56Z9wOVXY/oEz6Agj1RUrfCYWCjQKZv0JLOXIBoOOlv Q8hbCFnTNLTUMvqEihH2Ex0+JSwrpMrHj7r6Hw0= X-Google-Smtp-Source: AMrXdXs+K11RSQHl7BZzOXMzsBXeVAtjZXANZMNV++bg6uNPighTEjGccH/wGUdZXMbOATCd75iu3/VbjOdeLwNas9c= X-Received: by 2002:a05:6870:2c95:b0:144:c77a:1467 with SMTP id oh21-20020a0568702c9500b00144c77a1467mr1848242oab.272.1674470696249; Mon, 23 Jan 2023 02:44:56 -0800 (PST) MIME-Version: 1.0 References: <20230112.120338.534662300633460797.horikyota.ntt@gmail.com> In-Reply-To: From: Amit Kapila Date: Mon, 23 Jan 2023 16:14:44 +0530 Message-ID: Subject: Re: Time delayed LR (WAS Re: logical replication restrictions) To: Peter Smith Cc: "Takamichi Osumi (Fujitsu)" , vignesh C , Kyotaro Horiguchi , "Hayato Kuroda (Fujitsu)" , "shveta.malik@gmail.com" , "dilipbalaut@gmail.com" , "euler@eulerto.com" , "m.melihmutlu@gmail.com" , "andres@anarazel.de" , "marcos@f10.com.br" , "pgsql-hackers@postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 23, 2023 at 1:36 PM Peter Smith wrote: > > Here are my review comments for v19-0001. > ... > > 5. parse_subscription_options > > + /* > + * The combination of parallel streaming mode and min_apply_delay is not > + * allowed. The subscriber in the parallel streaming mode applies each > + * stream on arrival without the time of commit/prepare. So, the > + * subscriber needs to depend on the arrival time of the stream in this > + * case, if we apply the time-delayed feature for such transactions. Then > + * there is a possibility where some unnecessary delay will be added on > + * the subscriber by network communication break between nodes or other > + * heavy work load on the publisher. On the other hand, applying the delay > + * at the end of transaction with parallel apply also can cause issues of > + * used resource bloat and locks kept in open for a long time. Thus, those > + * features can't work together. > + */ > > IMO some re-wording might be warranted here. I am not sure quite how > to do it. Perhaps like below? > > SUGGESTION > > The combination of parallel streaming mode and min_apply_delay is not allowed. > > Here are some reasons why these features are incompatible: > a. In the parallel streaming mode the subscriber applies each stream > on arrival without knowledge of the commit/prepare time. This means we > cannot calculate the underlying network/decoding lag between publisher > and subscriber, and so always waiting for the full 'min_apply_delay' > period might include unnecessary delay. > b. If we apply the delay at the end of the transaction of the parallel > apply then that would cause issues related to resource bloat and locks > being held for a long time. > > ~~~ > How about something like: The combination of parallel streaming mode and min_apply_delay is not allowed. This is because we start applying the transaction stream as soon as the first change arrives without knowing the transaction's prepare/commit time. This means we cannot calculate the underlying network/decoding lag between publisher and subscriber, and so always waiting for the full 'min_apply_delay' period might include unnecessary delay. The other possibility is to apply the delay at the end of the parallel apply transaction but that would cause issues related to resource bloat and locks being held for a long time. > 6. defGetMinApplyDelay > > + > + > +/* > + * Extract the min_apply_delay mode value from a DefElem. This is very similar > + * to PGC_INT case of parse_and_validate_value(), because min_apply_delay > + * accepts the same string as recovery_min_apply_delay. > + */ > +int > +defGetMinApplyDelay(DefElem *def) > > 6a. > "same string" -> "same parameter format" ?? > > ~ > > 6b. > I thought this function should be implemented as static and located at > the top of the subscriptioncmds.c source file. > I agree that this should be a static function but I think its current location is a better place as other similar function is just above it. > > ====== > src/test/regress/sql/subscription.sql > > 9. Add new test? > > Should there be an additional test to check redundant parameter > setting -- eg. "... WITH (min_apply_delay=123, min_apply_delay=456)" > I don't think that will be of much help. We don't seem to have other tests for subscription parameters. -- With Regards, Amit Kapila.