Bug #106737 Wrong SE called to ack clone application if >1 SE
Submitted: 15 Mar 2022 11:52 Modified: 22 Oct 8:24
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Clone Plugin Severity:S4 (Feature request)
Version:8.0.28-8.0.32 OS:Any
Assigned to: CPU Architecture:Any
Tags: Clone

[15 Mar 2022 11:52] Laurynas Biveinis
Description:
If more than one clone-supporting SE is available, acknowledging clone application will send a remote command to the server with the SE locator with index zero, even if it's an incorrect one.

Part of the stacktrace:

  * frame #0: 0x0000000112412cf1 mysql_clone.so`myclone::Client::remote_command(this=0x0000700006064610, com=COM_ACK, use_aux=true) at clone_client.cc:1155:14
    frame #1: 0x00000001124163ad mysql_clone.so`myclone::Client_Cbk::buffer_cbk(this=0x0000600002634120, from_buffer=0x0000000000000000, buf_len=46) at clone_client.cc:1709:22
    frame #2: 0x00000001025c1572 mysqld`Clone_Handle::ack_state_metadata(this=0x000000011520ee20, task=0x000000011520ef58, callback=0x0000600002634120, state_desc=0x0000700006063ca8) at clone0apply.cc:636:24
    frame #3: 0x00000001025c1378 mysqld`Clone_Handle::apply_state_metadata(this=0x000000011520ee20, task=0x000000011520ef58, callback=0x0000600002634120) at clone0apply.cc:594:11
    frame #4: 0x00000001025c2fb8 mysqld`Clone_Handle::apply(this=0x000000011520ee20, thd=0x000000011504c400, task_id=0, callback=0x0000600002634120) at clone0apply.cc:1059:13
    frame #5: 0x0000000102569547 mysqld`innodb_clone_apply(hton=0x0000000111506800, thd=0x000000011504c400, loc="", loc_len=34, task_id=0, in_err=0, cbk=0x0000600002634120) at clone0api.cc:821:20
    frame #6: 0x0000000112415d39 mysql_clone.so`myclone::Client::set_descriptor(this=0x0000700006064610, buffer="", length=46) at clone_client.cc:1626:9

Suppose that at frame #6, loc_index == 1, and the InnoDB locator is there. But, Client::remote_command (frame #0) will call prepare_command_buffer which will call serialize_ack_cmd, which will use the following loc:

 auto loc = &m_share->m_storage_vec[m_conn_aux.m_cur_index];
 
where m_conn_aux.m_cur_index == 0, as it was never set to anything else in this code path.

How to repeat:
Code analysis due to not having a 2nd clone-supporting SE

Suggested fix:
Client::set_descriptor should have

clone_callback->set_loc_index(loc_index);

before clone_apply call to set m_conn_aux.m_cur_index to the correct value.
[15 Mar 2022 15:12] MySQL Verification Team
Hi Mr. Biveinis,

Thank you for your feature request.

We agree that this is a valid feature request that would improve our server functionality. We also agree that it would not require major rewrite of the existing code.

Verified as a feature request.
[15 Mar 2022 15:54] MySQL Verification Team
This report has been now accepted as a valid feature request.
[6 Sep 2022 13:49] Laurynas Biveinis
Bug 106737 fix for 8.0.30

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: bug106737.patch (application/octet-stream, text), 1.09 KiB.

[19 Sep 2022 11:04] MySQL Verification Team
Hi Laurynas,

Thank you for your contribution .....
[12 Oct 2022 12:10] Laurynas Biveinis
The patch applies to 8.0.31 too, MTR clone suite passes cleanly.
[12 Oct 2022 12:12] MySQL Verification Team
Thank you, Mr. Biveinis,

We checked and you are quite correct.
[17 Jan 2023 14:01] Laurynas Biveinis
Applies cleanly on 8.0.32 and does not regress MTR
[6 Feb 2023 12:31] MySQL Verification Team
Thanks a lot, Laurynas.
[20 Apr 2023 7:35] Laurynas Biveinis
Applies cleanly on 8.0.33 and does not regress MTR
[20 Apr 2023 11:55] MySQL Verification Team
Again, thanks a lot, Laurynas ........
[9 Jul 12:57] Laurynas Biveinis
My contributed patch applies cleanly on 9.0.0 and passes the tests.
[9 Jul 13:16] MySQL Verification Team
Thank you, Mr. Biveinis !!!!
[22 Oct 8:24] Laurynas Biveinis
The contributed patch applies on 9.1.0 cleanly and passes the tests.
[22 Oct 9:56] MySQL Verification Team
Thanks a lot ....

That is very good news.