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 1m5wKm-0000t6-V7 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jul 2021 20:27:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m5wKl-00010m-MG for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jul 2021 20:27:19 +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 1m5wKl-00010d-39 for pgsql-hackers@lists.postgresql.org; Tue, 20 Jul 2021 20:27:19 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m5wKf-0007qF-OI for pgsql-hackers@lists.postgresql.org; Tue, 20 Jul 2021 20:27:17 +0000 Received: by mail-wm1-x329.google.com with SMTP id b14-20020a1c1b0e0000b02901fc3a62af78so2200070wmb.3 for ; Tue, 20 Jul 2021 13:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rcCQlmrzqzxqnKTG6wRf/tBDff+YaAQTYgG57VU1yhI=; b=XWXDFxDqldfcbAt12KQhJDWfr2jaF4nQ0sMxh53fkPHUYiG7skpsv4Z6wzFL8zQq9h fVgSlpYPFewhM+hdjiv9OtHw2QXHxMZR2CY4n9Z2p1+Ez9ZXvsocN9w8in3+0x7NFCHq RLmYteeja0g1VNJ2VvKOtDUj3aCM5Dl3Yu+3HYQXe/fxh5b+1Y1EkmRdt/y74njNqvMO d05m7WrCwOnh+T9GtBY1ZondtvlvjBj30mA0JxMpyvCxYldtu0u6BXwjW3oIMjxBlynl z030F+MhZkg5hTuC8Y4trO3q3NpYwgfFbXoO8F9YcghtWcHb5KlLThxp69W415Yqw/Hj bCJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rcCQlmrzqzxqnKTG6wRf/tBDff+YaAQTYgG57VU1yhI=; b=I7BZHFF6hHlDQEHmkqm2khJxfI8ZKUNKbqSNjEIM0HdOkuIYYjp3zqnzI1cfexSeVp jN3HXNjMqWg9KNa6szhXV8vdvMx/Rkk1sGW5biiXnRGQP+CAPoRd6Le7Cs3vjCTbLnpK tOFSJJEXV/Twjw/sWTIrgRz03YokmB2gMOzbQj7apPABOnwBYaBJO2+zgx2e3uD6Adbh UFYvihMuafTo+CNNybY0sjUmFk26Xkz2lYG+WG90zKhf1Pfa2qojluishLwCKqyNpAQv AxQzoKCX+VAIufJ+ixT9DK7yCRWlpvEm61N9Vr+AVaTqIcap98VH6/3QSFWi7fCPvgnZ tYzQ== X-Gm-Message-State: AOAM533Xt2RheWQmdExCr57Q9+4+rc4Sz75vyF7BORMBk75RNw55Dl/q 6hDptnIT4LqTvab1HgRTzgb5VG/cOF8dc7Ay4JsT2mW7Hy/+4g9L6nyXmMc0Fa6K3RukKBNouzl f44a8usAbsv1ZxwaBnhH3C7UdF9VNXn1h/Nm8PvOF7O5aXg+GgjLI1uf34CeDC/UvW2zKDlFTYE pEXhsHna64xUBTKkmN1bGl42xhR7uegy8EiZYVEnMgANJIsc5siUHO X-Google-Smtp-Source: ABdhPJwZ0zh166A9CKt2POKF1yBfPK05+BI4n+8WocfNxvfnQS7HLHd96Zx9mFM2AifnNQ+u6hQeIA== X-Received: by 2002:a7b:cb53:: with SMTP id v19mr32609472wmj.127.1626812831963; Tue, 20 Jul 2021 13:27:11 -0700 (PDT) Received: from [10.137.0.19] (ip-86-49-254-183.net.upcbroadband.cz. [86.49.254.183]) by smtp.gmail.com with ESMTPSA id f11sm3204089wmb.14.2021.07.20.13.27.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Jul 2021 13:27:11 -0700 (PDT) Subject: Re: logical decoding and replication of sequences To: Peter Eisentraut , PostgreSQL Hackers Cc: Petr Jelinek References: <359bf6d0-413d-292a-4305-e99eeafead39@enterprisedb.com> From: Tomas Vondra Message-ID: <2dfe62e0-b600-9096-aa5c-7bd7cbc01378@enterprisedb.com> Date: Tue, 20 Jul 2021 22:27:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <359bf6d0-413d-292a-4305-e99eeafead39@enterprisedb.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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 7/20/21 5:30 PM, Peter Eisentraut wrote: > On 08.06.21 00:28, Tomas Vondra wrote: >> >> new "sequence" publication action >> --------------------------------- >> >> The publications now have a new "sequence" publication action, which is >> enabled by default. This determines whether the publication decodes >> sequences or what. >> >> >> FOR ALL SEQUENCES >> ----------------- >> >> It should be possible to create FOR ALL SEQUENCES publications, just >> like we have FOR ALL TABLES. But this produces shift/reduce conflicts >> in the grammar, and I didn't bother dealing with that. So for now it's >> required to do ALTER PUBLICATION ... [ADD | DROP] SEQUENCE ... > > I have been thinking about these DDL-level issues a bit.  The most > common use case will be to have a bunch of tables with implicit > sequences, and you just want to replicate them from here to there > without too much effort.  So ideally an implicit sequence should be > replicated by default if the table is part of a publication (unless > sequences are turned off by the publication option). > Agreed, that seems like a reasonable approach. > We already have support for things like that in > GetPublicationRelations(), where a partitioned table is expanded to > include the actual partitions.  I think that logic could be reused.  So > in general I would have GetPublicationRelations() include sequences and > don't have GetPublicationSequenceRelations() at all.  Then sequences > could also be sent by pg_publication_tables(), maybe add a relkind > column.  And then you also don't need so much duplicate DDL code, if you > just consider everything as a relation.  For example, there doesn't seem > to be an actual need to have fetch_sequence_list() and subsequent > processing on the subscriber side.  It does the same thing as > fetch_table_list(), so it might as well just all be one thing. > Not sure. I agree with replicating implicit sequences by default, without having to add them to the publication. But I think we should allow adding other sequences too, and I think some of this code and differentiation from tables will be needed. FWIW I'm not claiming there are no duplicate parts - I've mostly copy-pasted the table-handling code for sequences, and I'll look into reusing some of it. > We do, however, probably need some checking that we don't replicate > tables to sequences or vice versa. > True. I haven't tried doing such silly things yet. > We probably also don't need a separate FOR ALL SEQUENCES option.  What > users really want is a "for everything" option.  We could think about > renaming or alternative syntax, but in principle I think FOR ALL TABLES > should include sequences by default. > > Tests under src/test/subscription/ are needed. > Yeah, true. At the moment there are just tests in test_decoding, mostly because the previous patch versions did not add support for sequences to built-in replication. Will fix. > I'm not sure why test_decoding needs a skip-sequences option.  The > source code says it's for backward compatibility, but I don't see why we > need that. Hmmm, I'm a bit baffled by skip-sequences true. I think Cary added it to limit chances in test_decoding tests, while the misleading comment about backwards compatibility comes from me. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company