Bug #108867 Clone client returns ER_CLONE_DONOR for a client, not donor, error
Submitted: 25 Oct 2022 8:49 Modified: 25 Oct 2022 13:35
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Clone Plugin Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: Clone

[25 Oct 2022 8:49] Laurynas Biveinis
Description:
If the clone client is made to fail with an I/O error, it is reported as ER_CLONE_DONOR, implying that the error happened on the donor or on the connection to the donor, and not on the client side. Something else like ER_ERROR_ON_WRITE would seem to be more correct in this case.

How to repeat:
Fault injection:

diff --git a/storage/innobase/clone/clone0clone.cc b/storage/innobase/clone/clone0clone.cc
index 97f1b2d33b8..ba80669f588 100644
--- a/storage/innobase/clone/clone0clone.cc
+++ b/storage/innobase/clone/clone0clone.cc
@@ -2383,6 +2383,10 @@ int Clone_Handle::file_callback(Ha_clone_cbk *cbk, Clone_Task *task, uint len,
   } else {
     /* Write directly to file. */
     err = cbk->apply_file_cbk(file);
+    DBUG_EXECUTE_IF("innodb_clone_apply_fail", {
+        err = ER_ERROR_ON_WRITE;
+        set_my_errno(ENOSPC);
+      });
   }
 
 #ifdef UNIV_PFS_IO

MTR:

--source include/have_debug.inc

--let $HOST = 127.0.0.1
--let $PORT = `select @@port`
--let $USER = root
--let $remote_clone = 1
--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new

CREATE TABLE t1(col1 INT PRIMARY KEY, col2 CHAR(64));

INSERT INTO t1 VALUES(1, "string 1");
INSERT INTO t1 VALUES(2, "string 2");
INSERT INTO t1 VALUES(3, "string 3");

--replace_result $CLONE_PLUGIN CLONE_PLUGIN
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'

--source ../../clone/include/clone_connection_begin.inc

SET GLOBAL DEBUG="+d,innodb_clone_apply_fail";
--let clone_err = ER_CLONE_DONOR # <-------------------------- does not look correct
--source ../../clone/include/clone_command.inc
SET GLOBAL DEBUg="-d,innodb_clone_apply_fail";

--source ../../clone/include/clone_connection_end.inc

--connection default
DROP TABLE t1;
UNINSTALL PLUGIN clone;

--force-rmdir $CLONE_DATADIR

Running the MTR:

...
CLONE INSTANCE FROM USER@HOST:PORT IDENTIFIED BY '' DATA DIRECTORY = 'CLONE_DATADIR';
ERROR HY000: Clone Donor Error: 1026 : Error writing file 'Clone File' (errno: 0 - Undefined error: 0).

If the clone_err is set to ER_ERROR_ON_WRITE, the test fails.
[25 Oct 2022 9:00] Laurynas Biveinis
Also note that the fault injection tried to set errno = ENOSPC whereas the reported message says errno = 0
[25 Oct 2022 13:35] MySQL Verification Team
Hello Laurynas,

Thank you for the report and feedback!

regards,
Umesh