MDEV-39788: Remove added line in master.info format - #5301
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses compatibility issues in parsing *.info files (specifically master.info and relay-log.info) from older MariaDB/MySQL versions, ensuring that line counts and position values greater than 2^31 are handled correctly. It introduces a LINE_COUNT_FIX pseudo-value in Master_info_file to restore compatibility with files generated by MariaDB 10.0+ and updates the padding and saving logic in Info_file. Additionally, new tests are added to verify these changes. The review feedback suggests naming the unnamed struct LINE_COUNT_FIX to Line_count_fix_t to improve readability and prevent potential compiler-specific issues, along with a minor typo correction in the documentation.
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.
| protected: | ||
| /** | ||
| @ref Master_info_file has been inconsistent that its line count included | ||
| the line-count "value", while @ref Relay_log_info_file's excludes it. | ||
| Although the use common code now makes @ref Master_info_file match, | ||
| files from older versions are now off-by-one to Info_file::load_from_file(). | ||
| The presence of this non-reading pseudo-value restores | ||
| compatibility with files generated by MariaDB 10.0+, | ||
| as the driver loop will increment the line counter for it, | ||
| thus emulating counting the line-count "value". | ||
| @deprecated This is not needed after all pre-12.3 versions go EoL. | ||
| */ | ||
| struct: Persistent | ||
| { | ||
| bool load_from(IO_CACHE *file) override { return false; } ///< No-op | ||
| void save_to(IO_CACHE *file) override {} ///< No-op | ||
| } LINE_COUNT_FIX; |
There was a problem hiding this comment.
Naming the unnamed struct Line_count_fix_t improves code readability and avoids potential compiler-specific issues with unnamed classes overriding virtual functions or being used in template-based pointer-to-member wrappers. Additionally, there is a minor typo in the comment: 'use common code' should be 'use of common code'.
protected:
/**
@ref Master_info_file has been inconsistent that its line count included
the line-count "value", while @ref Relay_log_info_file's excludes it.
Although the use of common code now makes @ref Master_info_file match,
files from older versions are now off-by-one to Info_file::load_from_file().
The presence of this non-reading pseudo-value restores
compatibility with files generated by MariaDB 10.0+,
as the driver loop will increment the line counter for it,
thus emulating counting the line-count "value".
@deprecated This is not needed after all pre-12.3 versions go EoL.
*/
struct Line_count_fix_t : Persistent
{
bool load_from(IO_CACHE *file) override { return false; } ///< No-op
void save_to(IO_CACHE *file) override {} ///< No-op
} LINE_COUNT_FIX;master.info not upgrading master_use_gtidmaster.info format
|
Hi @bnestere (when you’re back from vacation), |
bnestere
left a comment
There was a problem hiding this comment.
Hi @ParadoxV5 !
Just to confirm my understanding of your patch: you make the de-facto behavior of the line number exclusive treatment (i.e. matching the relay-log-info file behavior), and then the master_info_file has an extra no-op line to increment the total line count with no other affects, so it reads as inclusive. Is that right?
Well, this description matches the design before my latest push closer than my latest version. In the latest version, |
bnestere
left a comment
There was a problem hiding this comment.
Thanks for the fix @ParadoxV5 !
I've left a few notes.
|
Done @bnestere P.S. TODO squash when I rebase for merging |
knielsen
left a comment
There was a problem hiding this comment.
Thanks for this Jimmy. Looks good to me.
I didn't spend a lot of time to understand everything in detail, but looks very reasonable.
|
waiting for #5147 to reach 12.3 for good record… Update: |
The line-count lines in `master.info` and `relay-log.info`
have been inconsistent (off by one) since their introduction.
MDEV-37530 “fixed” this with its common code merger by chance,
changing `master.info` to use `relay-log.info`’s line-count definition.
This change, howëver, affected backward compatibility,
as `master.info` now expects an ignored MySQL-only line
where the first `key=value` option, `master_use_gtid`, is.
Since this legacy text-based format has limitations that make
it due for replacement, only code reüsablility is valuable,
and its consistency does not outweigh its compatibility.
Therefore, this commit solves this problem without reverting code by:
* Changing the writing code to be compatible with both interpretations
(albeit inconsistent with the reading code)
* Adding a shim entry to `master.info`’s list
to emulate prior versions’ reading behaviour
* Although this solution can only restore upgrade compatibility with
versions 10.0+, versions before MariaDB 10 have long been EOL.
While here, this commit also fixes code and
comments that contradict the actual effect.
[P.S.] The test for this regression is pushed to 10.11 in PR #5147.
Reviewed-by: Brandon Nesterenko <brandon.nesterenko@mariadb.com>
Note
This PR is based on #5147, which provides the regression test.
The line-count lines in
master.infoandrelay-log.infohave been inconsistent (off by one) since their introduction.MDEV-37530 “fixed” this with its common code merger by chance, changing
master.infoto userelay-log.info’s line-count definition.This change, howëver, affected backward compatibility, as
master.infonow expects an ignored MySQL-only line where the firstkey=valueoption,master_use_gtid, is.Since this legacy text-based format has limitations that make it due for replacement, only code reüsablility is valuable, and its consistency does not outweigh its compatibility.
Therefore, this commit solves this problem without reverting code by:
(albeit inconsistent with the reading code)
master.info’s list to emulate prior versions’ reading behaviourWhile here, this commit also fixes code and comments that contradict the actual effect.