Skip to content

MDEV-40023 Error on unknown commands in check_expected_crash_and_restart#5229

Open
FarihaIS wants to merge 1 commit into
MariaDB:mainfrom
FarihaIS:mdev-40023
Open

MDEV-40023 Error on unknown commands in check_expected_crash_and_restart#5229
FarihaIS wants to merge 1 commit into
MariaDB:mainfrom
FarihaIS:mdev-40023

Conversation

@FarihaIS

@FarihaIS FarihaIS commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

check_expected_crash_and_restart() in mariadb-test-run.pl silently ignores anything in the expect file that does not start with restart. This let typos like restart_abort fall through to a default restart and made bugs like MDEV-39153 easy to miss.

Fix:

  • Anchor the wait / restart / restart_bindir regexes and call mtr_error() on any unrecognized command
  • chomp $last_line before matching so error messages don't embed a newline
  • Skip empty last lines, since partial writes to the expect file can be observed before the intended command is fully written (same race the existing -z $expect_file check guards against)

restart_bindir is left in place as it is used during development to test binary/data migration between two build trees.

Release Notes

N/A

How can this PR be tested?

Execute the full MTR test suite — no test uses restart_bindir, so removing it should have no effect. The mtr_error() change will prevent any future invalid expect file commands from failing silently.

Basing the PR against the correct MariaDB version

  • This is a minor fix, and the PR is based against the main branch.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies the restart command handling in the MariaDB test suite by removing the unused restart_bindir command and its associated environment variable handling. It also introduces strict error checking for unknown commands in the expect file. The review feedback highlights that the regular expression /^restart/ is too loose and will match any command starting with "restart" (e.g., "restarting"), suggesting it be tightened to /^restart\s*$/ to prevent silently ignoring invalid commands.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread mysql-test/mariadb-test-run.pl Outdated
@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@FarihaIS
FarihaIS changed the base branch from 12.3 to main June 12, 2026 23:12
@FarihaIS
FarihaIS force-pushed the mdev-40023 branch 2 times, most recently from d5c4ed9 to 4ba8b27 Compare June 12, 2026 23:53
@FarihaIS
FarihaIS marked this pull request as ready for review June 13, 2026 00:19
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Jun 15, 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.

LGTM. Please stand by for the final review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Cleans up the .expect-file crash/restart control path in MTR by removing unused restart_bindir support and surfacing invalid expect-file commands as errors, to avoid silent misbehavior during crash/restart tests.

Changes:

  • Remove the restart_bindir handling from check_expected_crash_and_restart() and from start_mysqld.inc.
  • Treat unrecognized expect-file commands as fatal via mtr_error() (instead of silently ignoring them).
  • Skip empty expect-file lines to mitigate partial-write races.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
mysql-test/mariadb-test-run.pl Removes restart_bindir logic; adds stricter parsing/erroring for expect-file commands; skips empty lines.
mysql-test/include/start_mysqld.inc Removes generation of restart_bindir commands in expect files.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mysql-test/mariadb-test-run.pl Outdated
@midenok

midenok commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This was done for MDEV-25004 and was used to test upgrade between two build trees. I don't think removing such feature unused in main mtr workflow is a good idea. I've used it in the process of development and may use it later in such projects as MDEV-16417. It is useful for any development when you have to check how the binary data migrates the versions.

@midenok
midenok self-requested a review June 25, 2026 11:51

@midenok midenok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code is not dead, it is used in development.

@FarihaIS

Copy link
Copy Markdown
Contributor Author

@midenok thank you for your review, I had initially created this PR - and associated Jira MDEV-40023 - due to these two comments on my other PR (comment 1 and 2).

Could you please let me know what the consensus is and whether these changes are still valid? Thank you!

@midenok

midenok commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@midenok thank you for your review, I had initially created this PR - and associated Jira MDEV-40023 - due to these two comments on #5221 (comment #5221 (comment) and #5221 (review)).

Could you please let me know what the consensus is and whether these changes are still valid? Thank you!

@FarihaIS Like I said in this PR I disagree with these changes. Is there some different questions by the provided links? Sorry, I just cannot understand. Please solve your task by improving the code, not by removing it. Is it the answer to your questions?

@gkodinov
gkodinov removed the request for review from sanja-byelkin July 20, 2026 13:17
@gkodinov gkodinov assigned midenok and unassigned sanja-byelkin Jul 20, 2026
@FarihaIS FarihaIS changed the title MDEV-40023 Clean up dead code in check_expected_crash_and_restart MDEV-40023 Error on unknown commands in check_expected_crash_and_restart Jul 21, 2026
@FarihaIS
FarihaIS force-pushed the mdev-40023 branch 2 times, most recently from 3af3547 to 5c636b3 Compare July 21, 2026 18:30
@FarihaIS

FarihaIS commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @midenok, that makes sense - I wasn't aware restart_bindir was actively used in development as the comment on my other PR suggested otherwise.

I've rescoped this PR to keep restart_bindir intact and only address the underlying MDEV-39153 issue: mtr_error() on unrecognized expect-file commands, plus modifying the wait/restart regexes so typos actually reach that branch.

Please let me know if I have missed anything, thank you.

Also, noting here that this change depends on #5221, i.e. main.change_master_default.test still uses restart_abort: (fixed there), which the new mtr_error() correctly catches, so CI here will fail until #5221 is merged.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread mysql-test/mariadb-test-run.pl Outdated
Comment thread mysql-test/mariadb-test-run.pl
Comment thread mysql-test/mariadb-test-run.pl
@midenok

midenok commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@FarihaIS I think this one should be rebased on top of #5221. Also please resolve 3 last Copilot comments above. For non-legit ones just comment briefly why.

Anchor the wait/restart regexes in mariadb-test-run.pl and call
mtr_error() on anything else, so typos in expect files no longer fall
through to a default restart. Chomp $last_line before matching and skip
empty last lines to tolerate partial writes.

restart_bindir is kept; it is used during development to test upgrades
between two build trees.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
@FarihaIS

Copy link
Copy Markdown
Contributor Author

@midenok I addressed all the Copilot comments, thank you. As for the rebase on #5221, should I do this now (which would retarget this PR to 12.3, since #5221 is against 12.3), or wait for #5221 to merge first?

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.

6 participants