MDEV-8235: Expose check_slave_start_position as SQL function GTID_CHECK_POS()#4956
MDEV-8235: Expose check_slave_start_position as SQL function GTID_CHECK_POS()#4956ayush-jha123 wants to merge 2 commits into
Conversation
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
First, the formalities:
- please keep a single commit, with a commit message in it.
- please make sure all of the buildbot hosts compile and run successfully
Below are some of my thoughts on the functionality and its implementation and test coverage. You can ignore all of the below and take it with the final reviewer. Or address it and have a faster final review with these fixed.
81aa4a1 to
c4377de
Compare
This commit implements the GTID_CHECK_POS() SQL function, which allows validating if a given GTID position is reachable within the current set of binary logs. This is useful for external tools or orchestration layers to verify if a node is viable for replication start without actually initiating a slave connection. Features: - Returns 1 if all GTIDs in the requested state are reachable. - Returns 0 if any GTID in the requested state has been purged. - Propagates parsing errors for malformed GTID strings. - Derived from Item_bool_func to ensure native boolean handling. - Protected by HAVE_REPLICATION for safe embedded builds. Implemented via a thin wrapper over the engine-internal gtid_find_binlog_pos() logic.
c4377de to
bd30bf6
Compare
gkodinov
left a comment
There was a problem hiding this comment.
It's looking much better. Please make sure to address the comments below. This is my last batch of preliminary review comments.
Thanks for your efforts.
| } | ||
|
|
||
|
|
||
|
|
| return 0; | ||
| #else | ||
| bool is_reachable= false; | ||
| if (rpl_gtid_pos_check_reachable(gtid_str, &is_reachable)) |
There was a problem hiding this comment.
This fails to compile on buildbot (I'm assuming for the unit tests) as follows:
/home/buildbot/aarch64-debian-11/build/sql/item_func.cc: In member function ‘virtual bool Item_func_gtid_check_pos::val_bool()’:
/home/buildbot/aarch64-debian-11/build/sql/item_func.cc:841:7: error: ‘rpl_gtid_pos_check_reachable’ was not declared in this scope
841 | if (rpl_gtid_pos_check_reachable(gtid_str, &is_reachable))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please have a look.
fb66443 to
beeba7c
Compare
beeba7c to
ebb7195
Compare
|
Hi @gkodinov, I've just pushed the updated commit addressing your latest feedback: Compilaton: Added #include "sql_repl.h" to sql/item_func.cc to fix the scope error you observed on Buildbot. Thanks for the review, let me know if there's anything else! |
I’ve been diving deep into the replication source code for the last two weeks,
investigating MDEV-8235. I noticed this task has been open for a while and realized
how useful it would be for DBAs to have a simple way to check GTID availability
directly from the SQL layer.
After studying how check_slave_start_position() works internally, I’ve implemented
a user-facing version called GTID_CHECK_POS().
What this PR does:
in sql_repl.cc to avoid code duplication.
which makes it robust for automation scripts.
I’m really excited to contribute this to MariaDB and would appreciate feedback
on the implementation.