MDEV-14472 Assertion `is_current_stmt_binlog_format_row()' failed...
in THD::binlog_write_table_map
Problem:- So the issue is when the test case (mdev_14472) is run with debug
build , Assert DBUG_ASSERT(is_current_stmt_binlog_format_row()); is fired
in binlog_write_table_map.
Analysis:- When we lock table t1, and if t1 has some trigger which updates
another table then all other tables are also locked. So in the case of lock
t1(in mdev_14472 test case) we will lock t1, t2, t3 and t4. In next insert
command (t2 insert), we call handler->check_table_row_based from
write_locked_table_maps which updates the table handler
check_table_binlog_row_based_done to 1 and check_table_binlog_row_based_result
to 1 , it is set to one because this particular insert stmt is unsafe(because
of trigger on t4). The next insert stmt(insert t3) is safe so we will write
that in stmt format , but since we havent cleared the previous
check_table_binlog_row_based_result so it is logged in row format while
thd->is_current_stmt_binlog_format_row() is still 0, and this fires the
assert. So the question is why check_table_binlog_row_based_result is not
reseted because mark_used_tables_as_free_for_reuse skips locked tables
Solution:- We make mark_used_tables_as_free_for_reuse to reset
check_table_binlog_row_based_result even when table is locked
$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-static --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=. --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-static' ...
OK
$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+
$ cmake -DPLUGIN_AUTH_SOCKET=NO ../mariadb-server-10.2/
$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-none --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=. --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-none' ...
ERROR: 1126 Can't open shared library '.../plugin/auth_socket/auth_socket.so' (errno: 2, cannot open shared object file: No such file or directory)
2018-05-01 11:38:56 0 [ERROR] Aborting
$ cmake -DPLUGIN_AUTH_SOCKET=DYNAMIC ../mariadb-server-10.2/
$ scripts/mysql_install_db --datadir=/tmp/mysqldatadir-auth-dyn --auth-root-socket-user=dan --auth-root-authentication-method=socket --builddir=. --srcdir=../mariadb-server-10.2
Installing MariaDB/MySQL system tables in '/tmp/mysqldatadir-auth-dyn' ...
OK
$ ./sql/mysqld --datadir=/tmp/mysqldatadir-auth-dyn --lc-messages-dir=${PWD}/sql/share --plugin-dir=./plugin/auth_socket/
$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+
$ sudo make install
$ sudo chmod a+rwx /usr/local/mysql/data
$ cd /usr/local/mysql/
$ scripts/mysql_install_db --auth-root-socket-user=dan --auth-root-authentication-method=socket
Installing MariaDB/MySQL system tables in './data' ...
OK
..
$ bin/mysqld_safe
$ client/mysql -S /tmp/mysql.sock -e 'show create user dan@localhost'
+----------------------------------------------------------+
| CREATE USER for dan@localhost |
+----------------------------------------------------------+
| CREATE USER 'dan'@'localhost' IDENTIFIED VIA unix_socket |
+----------------------------------------------------------+