← Back to team overview

maria-developers team mailing list archive

Re: [MariaDB/server] Proper locking for mysql.gtid_slave_pos truncation (84b437d)

 

Sergey Vojtovich <notifications@xxxxxxxxxx> writes:

> ATTN @dr-m, @andrelkin, @SachinSetiya, @knielsen 

So IIUC, this is about incorrect usage of ha_truncate() in
rpl_slave_state::truncate_state_table().

This is used only for

  SET GLOBAL gtid_slave_pos = "..."

when all slave threads are stopped and nothing else is accessing the
gtid_pos table.

So it's fine to use ha_truncate() if that can be done easily (and
correctly). But it would also be fine just to loop and delete all rows one
by one in a normal transaction, if that is simpler. gtid_slave_pos is a
small table, there are normally only a few rows per active replication
domain.

I'm not myself very familiar with details of metadata locking etc. around
ha_truncate().

But looking at the code now, I don't understand why it only truncates one
table? If --gtid-pos-auto-engines is in effect, there could be multiple
tables... shouldn't they all be cleared when setting the gtid_slave_pos
variable? If so, maybe the delete-rows-one-by-one approach is in any case
preferable over ha_truncate, since it can then be done transactionally, to
not leave an inconsistent gtid_slave_pos state if one truncate fails and
another succeeds?

Hope this helps,

 - Kristian.


Follow ups