Skip to content

MDEV-13718 mysqltest crashes upon --sync_slave_with_master without active connection - #5934

Open
Swayam-code wants to merge 3 commits into
MariaDB:11.4from
Swayam-code:codex/mdev-13718-closed-connection
Open

Swayam-code wants to merge 3 commits into
MariaDB:11.4from
Swayam-code:codex/mdev-13718-closed-connection

Conversation

@Swayam-code

Copy link
Copy Markdown

save_master_pos and sync_slave_with_master dereference a null client handle after disconnecting the current connection. Report error 2006 and stop before selecting a slave.

The regression passes in all three binlog formats on Windows (11.4 Debug client, 13.2 Debug server). main.mysqltest hits the same shell-quoting failure before and after the fix.

MDEV-13718

…tive connection

Report the existing no-active-connection error before querying master
status. Stop sync_slave_with_master before it selects a slave after a
handled error.

Cover disconnected commands, connection preservation and successful
replication before and after the error.

Assisted-by: Codex:GPT-6
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Oct 21, 2026
@gkodinov gkodinov self-assigned this Oct 21, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

You have pinpointed the problem space very well. But I am offering some suggestions to make it more inline with the bug fixing process we follow.

Comment thread client/mysqltest.cc Outdated
Comment thread client/mysqltest.cc Outdated
case Q_SYNC_SLAVE_WITH_MASTER:
{
do_save_master_pos();
if (do_save_master_pos(command))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why fail if --save-master-pos fails?

Note that --save-master-pos is a comment. Comments are not supposed to have the script fail. In fact, you could execute the .test file in a SQL client and it will run and skip the comments.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After an expected error 2006, the early return skips the remaining sync step to avoid using stale master_pos. Would you prefer disconnected save/sync commands to report 2006, or silently do nothing like enable_optimizer_trace?

@gkodinov gkodinov Oct 22, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a good question. Probably one for the final review (so you can actually table this for now).

But I'll bite.

In my book --foo is a comment. Comments are not supposed to fail the script execution. It's OK to report a problem executing a comment. As a warning. But stop? It's against what comments are IMHO.

FWIW, mariadb-test can take the command in one of the following two ways:

  • as a comment:
   --save-master-pos
   SELECT 1;
  • as a command:
  save_master_pos;
  SELECT 2;

Right now I believe there's not much functional difference between the two. Except that if you copy and paste the scripts into e.g. mariadb CLI you'd get an error for the command and just a normal ignore for the comment.

It feels like we can extend that logic towards general optionality of the commands themselves.

But alas, it's not done: --connect ... fails and breaks the script in the same way connect ...; does.
And there's already too many existing test lines built upon that assumption to allow changing it easily.

So, as much as I don't find it natural, a comment can and does break the script execution.

But I was hoping that we can reverse that trend with new developments. Hence the ask.

Makes sense?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that makes sense. I will leave the warning-versus-error policy for final review as suggested and keep the current error 2006 behavior in this fix.

Comment thread mysql-test/suite/rpl/t/rpl_mysqltest_closed_connection.test Outdated
Comment thread client/mysqltest.cc Outdated


int do_save_master_pos()
int do_save_master_pos(struct st_command *command)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only command that does this?

I believe enable_optimizer_trace does the same too. Please check the rest as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enable_optimizer_trace already checks for a null mysql handle and returns before issuing a query. I found other command paths worth checking, but have not reproduced those yet, so the broader audit is still incomplete.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be the most typical question I'd ask during an internal code review. It's probably easier and faster to find these than to talk about them. But OK, point made and received. I'll defer to the final review again.

Swayam-code and others added 2 commits October 21, 2026 16:57
Restore the no-argument save_master_pos helper and use curr_command for
error handling. Label the connection echoes in the regression output.
Error 2006 handling and the sync early return remain unchanged.

Assisted-by: Codex:GPT-6

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Additional points made and acknowledged.

One thing I'd like to request before I hand it off to the final reviewer: please squash all of your 3 commits into a single one. We try to have one commit per logical change per developer. FWIW, github allows you to merge with rebase.

@gkodinov gkodinov assigned sanja-byelkin and unassigned gkodinov Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants