MDEV-7394 : Making slave_skip_errors writable at runtime when slave is stopped #4634
MDEV-7394 : Making slave_skip_errors writable at runtime when slave is stopped #4634Mahmoud-kh1 wants to merge 4 commits intoMariaDB:mainfrom
Conversation
87dbe8f to
3fa1017
Compare
|
The following test cases fail because they assume that slave_skip_errors is read only which is no longer true which making their checks fail also |
gkodinov
left a comment
There was a problem hiding this comment.
This is a preliminary review. I'd like to request changes mostly because there are tests that need to be re-recorded (and possibly fixed too).
The rest of the comments are just my own limited take on the change. Feel free to ignore and leave for the final review.
sql/slave.cc
Outdated
| /* Make @@slave_skip_errors show the nice human-readable value. */ | ||
| opt_slave_skip_errors= slave_skip_error_names; | ||
| /* we should not touch opt_slave_skip_errors here. we just build the printable string only. */ | ||
| (void) opt_slave_skip_errors; |
There was a problem hiding this comment.
remove all these lines please.
There was a problem hiding this comment.
thanks for your review I will do this
| START SLAVE; | ||
| --echo # should reduce error because slave is not stopped | ||
| --error ER_SLAVE_MUST_STOP | ||
| SET GLOBAL slave_skip_errors = "1040"; |
There was a problem hiding this comment.
please also add actual functionality tests for the newly set variable values.
There was a problem hiding this comment.
thanks for the great feedback.
I have added a new test I'd be grateful if you take a look on it , and should I fix the tests that fail because it expect the variable to be read-only or leave it for now.
| @@ -774,8 +774,15 @@ bool init_slave_skip_errors(const char* arg) | |||
| if (!arg || !*arg) // No errors defined | |||
| goto end; | |||
|
|
|||
| if (my_bitmap_init(&slave_error_mask,0,MAX_SLAVE_ERROR)) | |||
| DBUG_RETURN(1); | |||
| if (!slave_error_mask.bitmap) | |||
There was a problem hiding this comment.
This is bad pattern. I'd initialize the bitmap to empty at the start of the server as it's done now.
And I'd update its contents as needed without de-allocating and re-allocating it.
|
Thank you so much for implementing my 11 year old bug report. I'd be very grateful if you stick through the review process on this. There's a lot to keep correct in the server to implement this change. |
Make slave_skip_errors dynamic so it can be changed while the slave is stopped. Attempts to change it while the slave is running are rejected with a clear error.
3fa1017 to
440eec2
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Please just fix the spacing issues. The rest is pretty much as one expects it to be. Aside from some polishing. Once the space changes are gone I will do another round and approve it.
|
|
||
| /* Make @@slave_skip_errors show the nice human-readable value. */ | ||
| opt_slave_skip_errors= slave_skip_error_names; | ||
|
|
| if (!(p= str2int(p, 10, 0, LONG_MAX, &err_code))) | ||
| break; | ||
| if (err_code < MAX_SLAVE_ERROR) | ||
| bitmap_set_bit(&slave_error_mask,(uint)err_code); |
There was a problem hiding this comment.
no white-space only changes please
|
|
||
| end: | ||
| make_slave_skip_errors_printable(); | ||
| end: |
There was a problem hiding this comment.
no whitespace only changes please
| } | ||
| if (ret) | ||
| rgi->last_event_start_time= 0; | ||
There was a problem hiding this comment.
no whitespace only changes please
sql/slave.cc
Outdated
| SLAVE_WAIT_GROUP_DONE ? FALSE : TRUE; | ||
|
|
||
| DBUG_EXECUTE_IF("stop_slave_middle_group", | ||
| DBUG_EXECUTE_IF("stop_slave_middle_group", |
There was a problem hiding this comment.
no whitespace only changes please
| #endif | ||
|
|
||
| return FALSE; | ||
| return FALSE; |
| It's necessary to adjust FD_q.(A) at this point because in the following | ||
| course FD_q is going to be dumped to RL. | ||
| Generally FD_q is derived from a received FD_m (roughly FD_q := FD_m) | ||
| Generally FD_q is derived from a received FD_m (roughly FD_q := FD_m) |
| DBUG_ASSERT(mi->rli.relay_log.description_event_for_queue->used_checksum_alg != | ||
| BINLOG_CHECKSUM_ALG_UNDEF); | ||
| DBUG_ASSERT(mi->rli.relay_log.relay_log_checksum_alg != | ||
| BINLOG_CHECKSUM_ALG_UNDEF); |
There was a problem hiding this comment.
last whitespace remark. you get the gist: don't do that. for the whole file.
| mysql_mutex_unlock(&LOCK_global_system_variables); | ||
| mysql_mutex_lock(&LOCK_active_mi); | ||
|
|
||
| if (give_error_if_slave_running(1)) |
There was a problem hiding this comment.
Interesting question: if the slave's not running, is there something to even access the skip errors list?
I'd guess not? I noticed that the other update methods would just check if the slave is running (and pass 0 here) and if it isn't they'd just do the update of the global values. I know what you did here is better. But I wonder if what the other methods are doing isn't enough?
There was a problem hiding this comment.
it's just a flag to this function if 0 means we don't hold LOCK_acitve_mi and the function do and release after checking , but here I need to hold this lock to the end until the update is done so I pass 1 to tell it I will control this lock
| my_error(ER_SLAVE_MUST_STOP, MYF(0)); | ||
| res= true; | ||
| } | ||
| else |
There was a problem hiding this comment.
Ignore please if you want, but this goes a bit against the coding style in the rest of the server.
It's usually like this:
bool err = false;
if (do_something_and_it_fails())
{
err = true;
}
if (!err && do something_else_and_it_fails())
{
err = true;
}
There was a problem hiding this comment.
please also fix the failing tests!
There was a problem hiding this comment.
I will go with your advice for sure and follow the same pattern
Removed unnecessary blank lines before the conditional check.
Now we can update slave_skip_errors at runtime when slaves stopped
to be changed at runtime when the replication slave is stopped.
server restart to be changed.
running preventing inconsistent replication state.
Key Changes
slave is stopped.
when the variable is changed.
dynamically when the slave is stopped and verified that updates are rejected while the slave is running.
behavior now is like that :

Feature :
MDEV-7394