-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDEV-35694: Mysqlbinlog --stop-position should warn if EOF not reached with --read-from-remote-server #3757
base: 10.5
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,6 +143,7 @@ static uint verbose= 0; | |
|
||
static ulonglong start_position, stop_position; | ||
static const longlong stop_position_default= (longlong)(~(my_off_t)0); | ||
static ulonglong last_processed_position= 0; | ||
#define start_position_mot ((my_off_t)start_position) | ||
#define stop_position_mot ((my_off_t)stop_position) | ||
|
||
|
@@ -997,6 +998,8 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, | |
determining how to print. | ||
@param[in] ev Log_event to process. | ||
@param[in] pos Offset from beginning of binlog file. | ||
@param[in] ev_end_pos Offset that represents the end of the event in the | ||
binlog file. | ||
@param[in] logname Name of input binlog. | ||
|
||
@retval ERROR_STOP An error occurred - the program should terminate. | ||
|
@@ -1005,7 +1008,8 @@ static bool print_row_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, | |
events to process has been reached and the program should terminate. | ||
*/ | ||
Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, | ||
my_off_t pos, const char *logname) | ||
my_off_t pos, my_off_t ev_end_pos, | ||
const char *logname) | ||
{ | ||
char ll_buff[21]; | ||
Log_event_type ev_type= ev->get_type_code(); | ||
|
@@ -1462,6 +1466,7 @@ Exit_status process_event(PRINT_EVENT_INFO *print_event_info, Log_event *ev, | |
end: | ||
rec_count++; | ||
last_processed_datetime= ev_when; | ||
last_processed_position= ev_end_pos; | ||
|
||
DBUG_PRINT("info", ("end event processing")); | ||
/* | ||
|
@@ -2379,7 +2384,8 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info, | |
if (old_off != BIN_LOG_HEADER_SIZE) | ||
*len= 1; // fake event, don't increment old_off | ||
} | ||
Exit_status retval= process_event(print_event_info, ev, old_off, logname); | ||
Exit_status retval= process_event(print_event_info, ev, old_off, | ||
old_off + (*len - 1), logname); | ||
if (retval != OK_CONTINUE) | ||
DBUG_RETURN(retval); | ||
} | ||
|
@@ -2397,7 +2403,8 @@ static Exit_status handle_event_text_mode(PRINT_EVENT_INFO *print_event_info, | |
DBUG_RETURN(ERROR_STOP); | ||
} | ||
|
||
retval= process_event(print_event_info, ev, old_off, logname); | ||
retval= process_event(print_event_info, ev, old_off, old_off + (*len - 1), | ||
logname); | ||
if (retval != OK_CONTINUE) | ||
{ | ||
my_close(file,MYF(MY_WME)); | ||
|
@@ -2794,9 +2801,9 @@ static Exit_status check_header(IO_CACHE* file, | |
the new one, so we should not do it ourselves in this | ||
case. | ||
*/ | ||
Exit_status retval= process_event(print_event_info, | ||
new_description_event, tmp_pos, | ||
logname); | ||
Exit_status retval= | ||
process_event(print_event_info, new_description_event, tmp_pos, | ||
my_b_tell(file), logname); | ||
if (retval != OK_CONTINUE) | ||
return retval; | ||
} | ||
|
@@ -2944,22 +2951,10 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, | |
} | ||
// else file->error == 0 means EOF, that's OK, we break in this case | ||
|
||
/* | ||
Emit a warning in the event that we finished processing input | ||
before reaching the boundary indicated by --stop-position. | ||
*/ | ||
if (((longlong)stop_position != stop_position_default) && | ||
stop_position > my_b_tell(file)) | ||
{ | ||
retval = OK_STOP; | ||
warning("Did not reach stop position %llu before " | ||
"end of input", stop_position); | ||
} | ||
|
||
goto end; | ||
} | ||
if ((retval= process_event(print_event_info, ev, old_off, logname)) != | ||
OK_CONTINUE) | ||
if ((retval= process_event(print_event_info, ev, old_off, my_b_tell(file), | ||
logname)) != OK_CONTINUE) | ||
goto end; | ||
} | ||
|
||
|
@@ -3138,6 +3133,15 @@ int main(int argc, char** argv) | |
warning("Did not reach stop datetime '%s' before end of input", | ||
stop_datetime_str); | ||
|
||
/* | ||
Emit a warning in the event that we finished processing input | ||
before reaching the boundary indicated by --stop-position. | ||
*/ | ||
if ((static_cast<longlong>(stop_position) != stop_position_default) && | ||
stop_position > last_processed_position) | ||
warning("Did not reach stop position %llu before end of input", | ||
stop_position); | ||
Comment on lines
3133
to
+3143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ☑️ Things are consistent with Funny. The code used to check/warn datetime after position, but now it’s before. 😀 |
||
|
||
/* | ||
If enable flashback, need to print the events from the end to the | ||
beginning | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison down there looks so wrong having to cast (C-style or
static_const
).Will an unsigned do? Or even a this-file-only macro-constant?
or
ULLONG_MAX
orstd::numeric_limits<unsigned long long>::max()
…Rather, specializing this value would put ~0 as an input out of support, though I don’t think it has a practical difference from “your file is bigger than the legal limit”.