Skip to content

MDEV-39223 Reversed executable comments incorrectly written in binlog#4885

Open
tonychen2001 wants to merge 1 commit intoMariaDB:mainfrom
tonychen2001:MDEV-39223
Open

MDEV-39223 Reversed executable comments incorrectly written in binlog#4885
tonychen2001 wants to merge 1 commit intoMariaDB:mainfrom
tonychen2001:MDEV-39223

Conversation

@tonychen2001
Copy link
Copy Markdown
Contributor

@tonychen2001 tonychen2001 commented Mar 31, 2026

Description

This addresses an issue introduced in #4724.

When a reversed executable comment (/*!!version */ or /*M!!version */)
is not executed on the master (server version >= specified version),
the binlog writer only neutralized the second '!' to a space, leaving
/*! command */, an executable comment. The slave would then try to
execute the comment body as SQL and fail with a parse error.

Fix: in the non-executed path, also replace the first '!' with a space so the
SQL becomes /* (a plain comment). The restore path for unclosed comments also
restores both '!' characters.

How can this PR be tested?

Added rpl_reversed_comments.test mirroring rpl_conditional_comments.test
with equivalent test cases:

  • mix of applied/not-applied
  • prepared statements
  • unclosed comments,
  • nested comments
  • delimiter edge case
  • MariaDB-specific /*M!! syntax

Basing the PR against the correct MariaDB version

  • This is a bug fix, and the PR is based against the branch main as the 13.0 branch does not exist at the moment.

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.

When a reversed executable comment (/*!!version */ or /*M!!version */)
is not executed on the master (server version >= specified version),
the binlog writer only neutralized the second '!' to a space, leaving
`/*! command */`, an executable comment. The slave would then try to
execute the comment body as SQL and fail with a parse error.

Fix: in the non-executed path, also replace the first '!' with a space so the
SQL becomes /*  (a plain comment). The restore path for unclosed comments also
restores both '!' characters.

Added rpl_reversed_comments.test mirroring rpl_conditional_comments.test
with reversed equivalents for all forward comment replication test cases:
mix of applied/not-applied, prepared statements, unclosed comments,
nested comments, delimiter edge case, and MariaDB-specific /*M!! syntax.

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.
@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Apr 1, 2026
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this so fast! This is a preliminary review.

LGTM.

Please stand by for the final review.

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