1. 24 Aug, 2021 1 commit
    • Amit Kapila's avatar
      Fix Alter Subscription's Add/Drop Publication behavior. · 5cfcd46e
      Amit Kapila authored
      The current refresh behavior tries to just refresh added/dropped
      publications but that leads to removing wrong tables from subscription. We
      can't refresh just the dropped publication because it is quite possible
      that some of the tables are removed from publication by that time and now
      those will remain as part of the subscription. Also, there is a chance
      that the tables that were part of the publication being dropped are also
      part of another publication, so we can't remove those.
      
      So, we decided that by default, add/drop commands will also act like
      REFRESH PUBLICATION which means they will refresh all the publications. We
      can keep the old behavior for "add publication" but it is better to be
      consistent with "drop publication".
      
      Author: Hou Zhijie
      Reviewed-by: Masahiko Sawada, Amit Kapila
      Backpatch-through: 14, where it was introduced
      Discussion: https://postgr.es/m/OS0PR01MB5716935D4C2CC85A6143073F94EF9@OS0PR01MB5716.jpnprd01.prod.outlook.com
      5cfcd46e
  2. 19 Jul, 2021 1 commit
  3. 25 Jun, 2021 1 commit
  4. 06 Apr, 2021 1 commit
  5. 12 Feb, 2021 2 commits
    • Amit Kapila's avatar
      Fix Subscription test added by commit ce0fdbfe. · c8b21b03
      Amit Kapila authored
      We want to test the variants of Alter Subscription that are not allowed in
      the transaction block but for that, we don't need to create a subscription
      that tries to connect to the publisher. As such, there is no problem with
      this test but it is good to allow such tests to run with
      wal_level = minimal and max_wal_senders = 0 so as to keep them consistent
      with other tests.
      
      Reported by buildfarm.
      
      Author: Amit Kapila
      Reviewed-by: Ajin Cherian
      Discussion: https://postgr.es/m/CAA4eK1Lw0V+e1JPGHDq=+hVACv=14H8sR+2eJ1k3PEgwKmU-jQ@mail.gmail.com
      c8b21b03
    • Amit Kapila's avatar
      Allow multiple xacts during table sync in logical replication. · ce0fdbfe
      Amit Kapila authored
      For the initial table data synchronization in logical replication, we use
      a single transaction to copy the entire table and then synchronize the
      position in the stream with the main apply worker.
      
      There are multiple downsides of this approach: (a) We have to perform the
      entire copy operation again if there is any error (network breakdown,
      error in the database operation, etc.) while we synchronize the WAL
      position between tablesync worker and apply worker; this will be onerous
      especially for large copies, (b) Using a single transaction in the
      synchronization-phase (where we can receive WAL from multiple
      transactions) will have the risk of exceeding the CID limit, (c) The slot
      will hold the WAL till the entire sync is complete because we never commit
      till the end.
      
      This patch solves all the above downsides by allowing multiple
      transactions during the tablesync phase. The initial copy is done in a
      single transaction and after that, we commit each transaction as we
      receive. To allow recovery after any error or crash, we use a permanent
      slot and origin to track the progress. The slot and origin will be removed
      once we finish the synchronization of the table. We also remove slot and
      origin of tablesync workers if the user performs DROP SUBSCRIPTION .. or
      ALTER SUBSCRIPTION .. REFERESH and some of the table syncs are still not
      finished.
      
      The commands ALTER SUBSCRIPTION ... REFRESH PUBLICATION and
      ALTER SUBSCRIPTION ... SET PUBLICATION ... with refresh option as true
      cannot be executed inside a transaction block because they can now drop
      the slots for which we have no provision to rollback.
      
      This will also open up the path for logical replication of 2PC
      transactions on the subscriber side. Previously, we can't do that because
      of the requirement of maintaining a single transaction in tablesync
      workers.
      
      Bump catalog version due to change of state in the catalog
      (pg_subscription_rel).
      
      Author: Peter Smith, Amit Kapila, and Takamichi Osumi
      Reviewed-by: Ajin Cherian, Petr Jelinek, Hou Zhijie and Amit Kapila
      Discussion: https://postgr.es/m/CAA4eK1KHJxaZS-fod-0fey=0tq3=Gkn4ho=8N4-5HWiCfu0H1A@mail.gmail.com
      ce0fdbfe
  6. 03 Sep, 2020 1 commit
    • Amit Kapila's avatar
      Add support for streaming to built-in logical replication. · 46482432
      Amit Kapila authored
      To add support for streaming of in-progress transactions into the
      built-in logical replication, we need to do three things:
      
      * Extend the logical replication protocol, so identify in-progress
      transactions, and allow adding additional bits of information (e.g.
      XID of subtransactions).
      
      * Modify the output plugin (pgoutput) to implement the new stream
      API callbacks, by leveraging the extended replication protocol.
      
      * Modify the replication apply worker, to properly handle streamed
      in-progress transaction by spilling the data to disk and then
      replaying them on commit.
      
      We however must explicitly disable streaming replication during
      replication slot creation, even if the plugin supports it. We
      don't need to replicate the changes accumulated during this phase,
      and moreover we don't have a replication connection open so we
      don't have where to send the data anyway.
      
      Author: Tomas Vondra, Dilip Kumar and Amit Kapila
      Reviewed-by: Amit Kapila, Kuntal Ghosh and Ajin Cherian
      Tested-by: Neha Sharma, Mahendra Singh Thalor and Ajin Cherian
      Discussion: https://postgr.es/m/688b0b7f-2f6c-d827-c27b-216a8e3ea700@2ndquadrant.com
      46482432
  7. 18 Jul, 2020 1 commit
  8. 29 Jun, 2019 1 commit
    • Tom Lane's avatar
      Fix regression tests to use only global names beginning with "regress_". · ca129e58
      Tom Lane authored
      In commit 18555b13 we tentatively established a rule that regression
      tests should use names containing "regression" for databases, and names
      starting with "regress_" for all other globally-visible object names, so
      as to circumscribe the side-effects that "make installcheck" could have on
      an existing installation.  However, no enforcement mechanism was created,
      so it's unsurprising that some new violations have crept in since then.
      
      In fact, a whole new *category* of violations has crept in, to wit we now
      also have globally-visible subscription and replication origin names, and
      "make installcheck" could very easily clobber user-created objects of
      those types.  So it's past time to do something about this.
      
      This commit sanitizes the tests enough that they will pass (i.e. not
      generate any visible warnings) with the enforcement mechanism I'll add
      in the next commit.  There are some TAP tests that still trigger the
      warnings, but the warnings do not cause test failure.  Since these tests
      do not actually run against a pre-existing installation, there's no need
      to worry whether they could conflict with user-created objects.
      
      The problem with rolenames.sql testing special role names like "user"
      is still there, and is dealt with only very cosmetically in this patch
      (by hiding the warnings :-().  What we actually need to do to be safe is
      to take that test script out of "make installcheck" altogether, but that
      seems like material for a separate patch.
      
      Discussion: https://postgr.es/m/16638.1468620817@sss.pgh.pa.us
      ca129e58
  9. 28 May, 2019 1 commit
  10. 17 May, 2019 1 commit
  11. 06 Jun, 2017 1 commit
  12. 18 May, 2017 1 commit
  13. 17 May, 2017 1 commit
    • Peter Eisentraut's avatar
      Add more tests for CREATE SUBSCRIPTION · 3db22794
      Peter Eisentraut authored
      Add some tests for parsing different option combinations.  Fix some of
      the resulting error messages for recent changes in option naming.
      
      Author: Masahiko Sawada <sawada.mshk@gmail.com>
      3db22794
  14. 12 May, 2017 1 commit
  15. 09 May, 2017 1 commit
  16. 08 May, 2017 1 commit
  17. 17 Apr, 2017 1 commit
  18. 14 Apr, 2017 1 commit
  19. 25 Mar, 2017 3 commits
  20. 23 Mar, 2017 1 commit
    • Peter Eisentraut's avatar
      Logical replication support for initial data copy · 7c4f5240
      Peter Eisentraut authored
      Add functionality for a new subscription to copy the initial data in the
      tables and then sync with the ongoing apply process.
      
      For the copying, add a new internal COPY option to have the COPY source
      data provided by a callback function.  The initial data copy works on
      the subscriber by receiving COPY data from the publisher and then
      providing it locally into a COPY that writes to the destination table.
      
      A WAL receiver can now execute full SQL commands.  This is used here to
      obtain information about tables and publications.
      
      Several new options were added to CREATE and ALTER SUBSCRIPTION to
      control whether and when initial table syncing happens.
      
      Change pg_dump option --no-create-subscription-slots to
      --no-subscription-connect and use the new CREATE SUBSCRIPTION
      ... NOCONNECT option for that.
      
      Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
      Tested-by: default avatarErik Rijkers <er@xs4all.nl>
      7c4f5240
  21. 15 Mar, 2017 1 commit
  22. 08 Mar, 2017 1 commit
  23. 04 Mar, 2017 1 commit
  24. 03 Mar, 2017 1 commit
  25. 20 Jan, 2017 1 commit