Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-1559

Debezium should not use SHARE UPDATE EXCLUSIVE MODE locks

    XMLWordPrintable

Details

    Description

      As per the docs regarding taking snapshots:

      Obtain a SHARE UPDATE EXCLUSIVE MODE lock on each of the monitored tables to ensure that no structural changes can occur to any of the tables while the snapshot is taking place. Note that these locks do not prevent table INSERTS, UPDATES and DELETES from taking place during the operation.

      If that description is accurate, then SHARE UPDATE EXCLUSIVE is too strong. All that is required and absolutely should be used instead is a lock in ACCESS SHARE MODE.

      This is very significant, because ACCESS SHARE only requires read-only access to the tables, which is the only access debezium should have as a replication user. SHARE UPDATE EXCLUSIVE requires that we give write permissions to the debezium user to every table.

      PR: https://github.com/debezium/debezium/pull/1083

      Straightforward demo:

      $ psql
      postgres=# create table lockme()
      postgres-# ;
      CREATE TABLE
      postgres=# begin;
      BEGIN
      postgres=# lock table lockme in access share mode;
      LOCK TABLE
      postgres=# \! psql -c 'set lock_timeout to 1000; alter table lockme add column foo int'
      ERROR:  canceling statement due to lock timeout
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jfinzel Jeremy Finzel
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: