>
> - Should Relay_log_info::purge_relay_logs set errmsg on failure to
> acquire binlog lock protection?
>
No, because setting errmsg would cause callers to call
my_error(ER_RELAY_LOG_FAIL, errmsg), which is not what we want, because
that would have been already called by MDL_context::acquire_lock().
> - Why does Slave_worker::reset_recovery_info try to acquire the
> binlog protection and proceeds to call the setter without
> considering whether the acquisition succeeded? That will fail
> the DBUG_ASSERT in the setter in the case of failure at
> least. If I understand the context of the code correctly, it
> should be just like the other protection sites instead, with an
> early error return in the case of failure.
>
For some reasons I wasn’t sure if the callers are able to handle errors
returned by Slave_worker::reset_recovery_info(), but I can’t recall
them. Anyway, this seems to be a rather corner case, so I changed to
return an error instead.
I have, yes. That would prevent some code duplication, but not too much,
as callers would still have to handle errors, the ‘protection_acquired’
flag + some of them also assert that the current connection has not
acquired the binlog lock, while the others do not. Which means the
wrapper code around those acquire/release helper functions would be
about the same number of lines replicating to every site. So I decided
to leave it as is for clarity.
> info::purge_ relay_logs set errmsg on failure to
> - Should Relay_log_
> acquire binlog lock protection?
>
No, because setting errmsg would cause callers to call ER_RELAY_ LOG_FAIL, errmsg), which is not what we want, because :acquire_ lock().
my_error(
that would have been already called by MDL_context:
> - Why does Slave_worker: :reset_ recovery_ info try to acquire the
> binlog protection and proceeds to call the setter without
> considering whether the acquisition succeeded? That will fail
> the DBUG_ASSERT in the setter in the case of failure at
> least. If I understand the context of the code correctly, it
> should be just like the other protection sites instead, with an
> early error return in the case of failure.
>
For some reasons I wasn’t sure if the callers are able to handle errors :reset_ recovery_ info(), but I can’t recall
returned by Slave_worker:
them. Anyway, this seems to be a rather corner case, so I changed to
return an error instead.
> - Have you considered extracting backup_ binlog_ lock_protection (thd, rli) binlog_ lock.is_ acquired( )) >variables. lock_wait_ timeout; assert_ not_owner( &rli->data_ lock); >backup_ binlog_ lock.acquire_ protection( thd, acquired) binlog_ lock.release_ protection( thd);
>
> bool rpl_acquire_
> {
> bool ret= true;
> if (thd && !thd->backup_
> {
> const ulong timeout= info_thd-
>
> DBUG_PRINT("debug", ("Acquiring binlog protection lock"));
>
> if (rli)
> mysql_mutex_
>
> ret= !info_thd-
> MDL_EXPLICIT, timeout);
> }
> return ret;
> }
>
> and void release(thd, bool protection_
> {
> if (thd && prot_acquired)
> {
> DBUG_PRINT("debug", ("Releasing binlog protection lock"));
> thd->backup_
> }
> }
I have, yes. That would prevent some code duplication, but not too much, acquired’
as callers would still have to handle errors, the ‘protection_
flag + some of them also assert that the current connection has not
acquired the binlog lock, while the others do not. Which means the
wrapper code around those acquire/release helper functions would be
about the same number of lines replicating to every site. So I decided
to leave it as is for clarity.
--
Best regards,
Alexey.