Skip to content

MDEV-40294 mariadb-binlog --start/stop-datetime incorrectly accepts o… - #5983

Open
Zeyadzahran wants to merge 1 commit into
MariaDB:11.4from
Zeyadzahran:MDEV-40294
Open

Zeyadzahran wants to merge 1 commit into
MariaDB:11.4from
Zeyadzahran:MDEV-40294

Conversation

@Zeyadzahran

Copy link
Copy Markdown

Jira: MDEV-40294

--start-datetime and --stop-datetime silently treated values outside of the TIMESTAMP range as 1970, so an over-max --start-datetime printed every event and an over-max --stop-datetime printed none.

my_system_gmt_sec() returns 0 and sets ER_WARN_DATA_OUT_OF_RANGE for such values, but convert_str_to_timestamp() never checked it. Now it prints a "Date and time argument out of range" warning and clamps over-max values to the max timestamp.

Tests: new cases in main.mysqlbinlog, which fail without the fix. main.mysqlbinlog and the related binlog tests pass on a debug build.

I am contributing my new code of the whole pull request, including one or several files that are either new files or modified ones, under the BSD-new license.

@CLAassistant

CLAassistant commented Oct 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Oct 26, 2026
@gkodinov gkodinov self-assigned this Oct 26, 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.

Please:

  1. address the test failures in buildbot
  2. add a commit message to your commit

Otherwise the change seems logical.

I'd do an error since this is changing what's explicitly been specified by the user. But I can live with a warning too. It's something for the final reviewer to decide I guess.

Comment thread mysql-test/main/mysqlbinlog.result Resolved

@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. Please stand by for the final review.

@gkodinov gkodinov assigned ParadoxV5 and unassigned gkodinov Oct 26, 2026
@Zeyadzahran

Copy link
Copy Markdown
Author

Thanks @gkodinov for the review! I addressed both points.

About error vs warning, my first approach was an error, but Jimmy suggested a warning with clamping in Jira, since values like these were accepted before and some scripts might not sanitize their inputs, so an error could break them.

@gkodinov
gkodinov requested a review from ParadoxV5 October 26, 2026 14:01

@ParadoxV5 ParadoxV5 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.

Thanks for helping out.

Comment thread client/mysqlbinlog.cc Resolved
Comment thread client/mysqlbinlog.cc Resolved
Comment thread mysql-test/main/mysqlbinlog.test Resolved
Comment thread mysql-test/main/mysqlbinlog.test Resolved
Comment thread mysql-test/main/mysqlbinlog.test Outdated
--echo # over-max timestamps
--echo #
--exec $MYSQL_BINLOG --short-form "--start-datetime=2106-02-08 00:00:00" $MYSQL_TEST_DIR/std_data/binlog_transaction.000001 2>&1
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2106-02-08 00:00:00" $MYSQL_TEST_DIR/std_data/binlog_transaction.000001 2> /dev/null

@ParadoxV5 ParadoxV5 Oct 30, 2026 •

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.

Well that’s a lot of data in the .result file, but only 2 warnings out of 3 test cases.
Did you mean?

Suggested change
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2106-02-08 00:00:00" $MYSQL_TEST_DIR/std_data/binlog_transaction.000001 2> /dev/null
--exec $MYSQL_BINLOG --short-form "--stop-datetime=2106-02-08 00:00:00" $MYSQL_TEST_DIR/std_data/binlog_transaction.000001 > /dev/null

If the test focuses on warnings, then it makes sense to squelch the stdout of all of these cases.
But I suppose this test doubles as a max-boundary output test; in this case, it’s better to keep them, with a smaller file to reduce output size.

(FYI, /dev/null might not work on Windoze (MDEV-41085), so error message tests like this use --result-file=path/to/throwaway_file.)

@ParadoxV5 ParadoxV5 Oct 30, 2026 •

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.

P.S.
Back-to-back binlog output can easily become unreadable without some --echo labels, though these warnings are sufficient dividers because they’re before the cases’ actual output.

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.

The 2> was on purpose because of the Windows issue (your comment on the .result). Now all 4 cases show their warnings, I switched to binlog_savepoint.000001 which is about half the size, and there's no /dev/null anymore. Also added an --echo before each case, it reads better.

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.

Choosing binlog_savepoint.000001 “for consistency with earlier in this test1” is okay.

Though, not far above your addition, there’s a test that generates $MYSQLD_DATADIR/master-bin.000001 (and doesn’t purge it in the name of corruption).
Looks like it’ll give an even smaller output.

(Size doesn’t matter too much; it’s about reducing the noise.
The option with the smallest yet sufficient output is most likely to generate a binlog file with only one entry.)

Footnotes

  1. apparently the only thing that uses binlog_savepoint.000001 ↩

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.

I tried a generated one, but it prints sql_mode and collation_server, which differ between builders, so it needs the same replace_regex as the other cases here. Felt like more noise in the .test than it saves in the .result, so I kept binlog_savepoint.000001.

@ParadoxV5 ParadoxV5 added the Replication Patches involved in replication label Oct 30, 2026
@Zeyadzahran
Zeyadzahran requested a review from ParadoxV5 October 30, 2026 06:01
…ver-max timestamps

For a value outside of the TIMESTAMP range, my_system_gmt_sec()
returns 0 and sets ER_WARN_DATA_OUT_OF_RANGE, but
convert_str_to_timestamp() never checked it. So such values silently
became 1970: an over-max --start-datetime printed every event and an
over-max --stop-datetime printed none.

Print a warning for out of range values and clamp the over-max ones
to the max timestamp. Under-min values already became the min.
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. Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

4 participants