Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-29848

Partially failed grant not written into binlog => discrepancy between master and replica

    XMLWordPrintable

Details

    Description

      If GRANT (I suppose REVOKE too, and maybe some other statements sharing the same logic) is executed partially but ends with an error, it isn't written into the binlog with an error code as is customary to do. Naturally it makes the data diverge between master and slave, and further replication is bound to abort.

      In the test case below, GRANT is called for an existing user foo and non-existing user bar. It is applied to foo on master, but not binary-logged, so it's not applied on the slave. Further operations (e.g. revoking the same grant) would cause replication abort.

      --source include/master-slave.inc
       
      set sql_mode=concat(@@sql_mode,',NO_AUTO_CREATE_USER'); # This is default, but just in case
       
      create user foo;
       
      --error ER_PASSWORD_NO_MATCH
      grant select on db.* to foo, bar;
      show grants for foo;
       
      # revoke select on db.* from foo; # <= if you want to get actual replication abort
       
      show binlog events;
      --sync_slave_with_master
      show grants for foo;
       
      # Cleanup
       
      --connection master
      drop user foo;
      --source include/rpl_end.inc
      

      10.3 9de37e07

      [connection master]
      set sql_mode=concat(@@sql_mode,',NO_AUTO_CREATE_USER');
      create user foo;
      grant select on db.* to foo, bar;
      ERROR 28000: Can't find any matching row in the user table
      show grants for foo;
      Grants for foo@%
      GRANT USAGE ON *.* TO `foo`@`%`
      GRANT SELECT ON `db`.* TO `foo`@`%`
      show binlog events;
      Log_name	Pos	Event_type	Server_id	End_log_pos	Info
      master-bin.000001	4	Format_desc	1	256	Server ver: 10.3.37-MariaDB-debug-log, Binlog ver: 4
      master-bin.000001	256	Gtid_list	1	285	[]
      master-bin.000001	285	Binlog_checkpoint	1	329	master-bin.000001
      master-bin.000001	329	Gtid	1	371	GTID 0-1-1
      master-bin.000001	371	Query	1	453	use `test`; create user foo
      connection slave;
      show grants for foo;
      Grants for foo@%
      GRANT USAGE ON *.* TO `foo`@`%`
      connection master;
      

      Reproducible on all current server versions.

      Attachments

        Activity

          People

            Elkin Andrei Elkin
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.