Bug #102240 clone plugin initialization fails when partly installed previously
Submitted: 13 Jan 2021 8:18 Modified: 19 Mar 2021 18:14
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Clone Plugin Severity:S3 (Non-critical)
Version:8.0.21, 8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[13 Jan 2021 8:18] Daniël van Eeden
Description:
When a previous attempt to install the clone plugin left a row in the mysql.plugin table the next attempt to install the plugin fails.

How to repeat:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.21    |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM information_schema.plugins WHERE plugin_name='clone'\G
Empty set (0.00 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
ERROR 3883 (HY000): Error installing plugin 'clone': got 'Operation not permitted' writing to mysql.plugin
mysql> SELECT * FROM mysql.plugin WHERE name='clone';
+-------+----------------+
| name  | dl             |
+-------+----------------+
| clone | mysql_clone.so |
+-------+----------------+
1 row in set (0.00 sec)

mysql> SET SESSION sql_log_bin=0;
Query OK, 0 rows affected (0.00 sec)

mysql> DELETE FROM mysql.plugin WHERE name='clone';
Query OK, 1 row affected (0.00 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
ERROR 1123 (HY000): Can't initialize function 'clone'; Plugin initialization function failed.
mysql> SELECT @@session.sql_mode;
+----------------------------------------------------------------------------------------------------------------------------------+
| @@session.sql_mode                                                                                                               |
+----------------------------------------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> SET SESSION sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'
    -> ;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
Query OK, 0 rows affected (0.78 sec)

(as you can see this session was also affected by Bug #102096 )

Suggested fix:
Use replace into or something similar to ignore this row already being present in the table.
[15 Jan 2021 9:27] MySQL Verification Team
Hello Daniël,

Thank you for the report and feedback.
I tried to reproduce this issue at my end on 8.0.22, by failed attempt (Bug #102096) but not seeing any entries in mysql.plugin table to trigger the issue as reported(of course manual INSERT will trigger the issue). Do you have any steps to trigger the issue? Please let us know. Thank you!

-
mysql> SET SESSION explicit_defaults_for_timestamp=OFF;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> SET SESSION sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)

mysql>  SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_NAME LIKE '%clone%';
Empty set (0.01 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
ERROR 1123 (HY000): Can't initialize function 'clone'; Plugin initialization function failed.
mysql>
mysql> SELECT * FROM mysql.plugin WHERE name='clone';
Empty set (0.00 sec)

mysql>
mysql> -- manually inserting row
mysql> insert into mysql.plugin values('clone','mysql_clone.so');
Query OK, 1 row affected (0.00 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
ERROR 3883 (HY000): Error installing plugin 'clone': got 'Operation not permitted' writing to mysql.plugin
mysql>

Agree, with your suggestion on "replace|ignore" if the row already exists.

regards,
Umesh
[18 Jan 2021 8:08] Daniël van Eeden
The entry in mysql.plugin wasn't inserted by me. This was left behind from a previous attempt to install the plugin that failed.
[20 Jan 2021 13:52] MySQL Verification Team
Thank you for Daniel.
Observed this on 8.0.23 build.

regards,
Umesh
[20 Jan 2021 13:53] MySQL Verification Team
-- build

cat docs/INFO_SRC
commit: c586d55f06bf915d6506e599deb87dbb89f2496a
date: 2020-12-10 06:56:16 +0100
build-date: 2020-12-11 07:43:19 +0000
short: c586d55f06b
branch: mysql-8.0.23-release

MySQL source 8.0.23

-- bring up mysqld

rm -rf 102096/
bin/mysqld --initialize-insecure --basedir=$PWD --datadir=$PWD/102096 --log-error-verbosity=3
bin/mysqld_safe --no-defaults --basedir=$PWD --datadir=$PWD/102096 --core-file --socket=/tmp/mysql_ushastry.sock  --port=3333 --log-error=$PWD/102096/log.err --mysqlx-port=33330 --mysqlx-socket=/tmp/mysql_x_ushastry.sock --log-error-verbosity=3  --secure-file-priv=/tmp/ 2>&1 &

- run from two terminal

yes "INSTALL PLUGIN clone SONAME 'mysql_clone.so';UNINSTALL PLUGIN clone;" | bin/mysql -uroot -S /tmp/mysql_ushastry.sock

yes "SET GLOBAL explicit_defaults_for_timestamp=OFF;set global sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_ENGINE_SUBSTITUTION';" | bin/mysql -uroot -S /tmp/mysql_ushastry.sock

Kill first instance of YES and then again attempt

yes "INSTALL PLUGIN clone SONAME 'mysql_clone.so';UNINSTALL PLUGIN clone;" | bin/mysql -uroot -S /tmp/mysql_ushastry.sock

 - Instantly got
 
  yes "INSTALL PLUGIN clone SONAME 'mysql_clone.so';UNINSTALL PLUGIN clone;" | bin/mysql -uroot -S /tmp/mysql_ushastry.sock
ERROR 3883 (HY000) at line 1: Error installing plugin 'clone': got 'Operation not permitted' writing to mysql.plugin

- checked from CLI

mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.23    |
+-----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM information_schema.plugins WHERE plugin_name='clone'\G
Empty set (0.00 sec)

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';
ERROR 3883 (HY000): Error installing plugin 'clone': got 'Operation not permitted' writing to mysql.plugin
mysql> SELECT * FROM mysql.plugin WHERE name='clone';
+-------+----------------+
| name  | dl             |
+-------+----------------+
| clone | mysql_clone.so |
+-------+----------------+
1 row in set (0.00 sec)
[19 Mar 2021 18:14] Paul DuBois
Posted by developer:
 
Fixed in 8.0.24.

A clone plugin installation failure could cause subsequent
installation attempts to fail.
[2 Apr 2024 14:36] Simon Mudd
Related: https://bugs.mysql.com/114529