Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAs83-008XH9-NB for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 13:39:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rAs81-009cAk-Hw for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Dec 2023 13:39:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAs81-009cAc-7V for pgsql-hackers@lists.postgresql.org; Wed, 06 Dec 2023 13:39:53 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rAs7t-00AOW2-NG for pgsql-hackers@lists.postgresql.org; Wed, 06 Dec 2023 13:39:51 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-40c0f3a7717so29197045e9.1 for ; Wed, 06 Dec 2023 05:39:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1701869984; x=1702474784; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YNHM0tB6ANJ+2hHeGB66jV+z9wkprw3+XdNkBSUKXsg=; b=C6IMj9UIhYUKcfO+gNulL6CaRfbGXK3+S1Q6xhVEoJV/yWSXigab0oM+ZzPys05JUr LaFvI0+lu5HUm7hOqFccc6KgGm4AanEuXuisArjlxxYIigXmi+BGeu2m6yUpyocsukPF mJm18OPPNoATBxmI6/NJBQrghBnv0WeYsgUHw1UT6XzWhIwn4IT8LCvtTKj3FTRGEXd5 dSVvNmOJEIvnxZ+gQ1RLPOc75NceRI5/0eVbSOjpUHjufwluq4WdJIvV51B7nlEDFvDt w5Z3CFiiJ44r+HVJEjDr9tEizXHWwHumXbv/vVEeF+WFa7uDbXSlHRwBZmiWoizrk1SX zr6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701869984; x=1702474784; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YNHM0tB6ANJ+2hHeGB66jV+z9wkprw3+XdNkBSUKXsg=; b=oxNxM4GQW8gygUkqnXGB8KSbUBpgFYY00b52lM13Ese3z72qwRzMgDQIhvwr0FdqVT 3Jld1pTl1vwVt7K+ZGkTVN/r7pUL1sB1SSwRMmkzM2aV4M6Jsgisf6yMQbGMiozY9QAv 6IJsyTh33AaWSHEDEUVFqJQunkhtXy5QQTL6s9xNjIi6cmP2Xbo/tj47efhtBqZ2Xv6l hEZzRcVhzwGZlUGu+uIuRIE+CKCDEwchZFgQ4rqNY1kvculnGRnHHTU6fQpbOdY8hJLG wQcVFQ2CN/aNd/Pg7T4qWVfqI8VtBNZuO0sr1WtJGi3MS/Da9tR0bQY29BV94Kp+J8KC Ajqw== X-Gm-Message-State: AOJu0YwfKJXKTDCodJ78hkdCltcouhZkmKTbFefI2N/KQYoehJjoPcYm dKBkfsrLPGQuPSR+mABBZh9YEQ== X-Google-Smtp-Source: AGHT+IExTQn4XOEbqrrR0G12C89sJ0yZXeSacC0mHAfysAZjo/9fMrNrokTTSDHymxRqitpaGgTxWw== X-Received: by 2002:a05:600c:5127:b0:40b:2c20:d044 with SMTP id o39-20020a05600c512700b0040b2c20d044mr359954wms.2.1701869983834; Wed, 06 Dec 2023 05:39:43 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id ld15-20020a170906f94f00b00a1b618766cbsm4999697ejb.136.2023.12.06.05.39.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 05:39:43 -0800 (PST) Message-ID: Date: Wed, 6 Dec 2023 14:39:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: logical decoding and replication of sequences, take 2 To: Dilip Kumar Cc: "Hayato Kuroda (Fujitsu)" , Amit Kapila , "Zhijie Hou (Fujitsu)" , Ashutosh Bapat , PostgreSQL Hackers , Masahiko Sawada , Peter Eisentraut References: <36f3a200-f185-887c-da08-fdc866436e6c@enterprisedb.com> <195be236-7580-72c6-97c7-59f06c4e093c@enterprisedb.com> <4954a4f8-ba9d-d352-571b-7b94372ea5ae@enterprisedb.com> <418ff5ac-1664-9038-8ac6-0dd308b5df07@enterprisedb.com> <8a2f25d8-23d4-4ab8-2a23-7c8d2d976209@enterprisedb.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/6/23 10:05, Dilip Kumar wrote: > On Wed, Dec 6, 2023 at 11:12 AM Dilip Kumar wrote: >> >> On Sun, Dec 3, 2023 at 11:22 PM Tomas Vondra >> wrote: >>> > > I was also wondering what happens if the sequence changes are > transactional but somehow the snap builder state changes to > SNAPBUILD_FULL_SNAPSHOT in between processing of the smgr_decode() and > the seq_decode() which means RelFileLocator will not be added to the > hash table and during the seq_decode() we will consider the change as > non-transactional. I haven't fully analyzed that what is the real > problem in this case but have we considered this case? what happens if > the transaction having both ALTER SEQUENCE and nextval() gets aborted > but the nextva() has been considered as non-transactional because > smgr_decode() changes were not processed because snap builder state > was not yet SNAPBUILD_FULL_SNAPSHOT. > Yes, if something like this happens, that'd be a problem: 1) decoding starts, with SnapBuildCurrentState(builder) < SNAPBUILD_FULL_SNAPSHOT 2) transaction that creates a new refilenode gets decoded, but we skip it because we don't have the correct snapshot 3) snapshot changes to SNAPBUILD_FULL_SNAPSHOT 4) we decode sequence change from nextval() for the sequence This would lead to us attempting to apply sequence change for a relfilenode that's not visible yet (and may even get aborted). But can this even happen? Can we start decoding in the middle of a transaction? How come this wouldn't affect e.g. XLOG_HEAP2_NEW_CID, which is also skipped until SNAPBUILD_FULL_SNAPSHOT. Or logical messages, where we also call the output plugin in non-transactional cases. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company