1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-14092 NEXTVAL fails on slave

The problem was that the code in replication didn't distinguish between a
setval() failing because the stored sequence number was bigger than the
current (should have been ignored) and a failure from the storage engine.
This commit is contained in:
Michael Widenius
2017-10-19 13:22:38 +03:00
parent e156db85a7
commit 211f9eea60
5 changed files with 260 additions and 12 deletions

View File

@ -758,12 +758,12 @@ void SEQUENCE_LAST_VALUE::set_version(TABLE *table)
@param in table Sequence table
@param in next_val Next free value
@param in next_round Round for 'next_value' (in cace of cycles)
@param in next_round Round for 'next_value' (in case of cycles)
@param in is_used 1 if next_val is already used
@retval 0 ok, value adjusted
1 value was less than current value or
error when storing value
-1 value was less than current value
1 error when storing value
@comment
A new value is set only if "nextval,next_round" is less than
@ -773,10 +773,10 @@ void SEQUENCE_LAST_VALUE::set_version(TABLE *table)
contain the highest used value when the slave is promoted to a master.
*/
bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round,
int SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round,
bool is_used)
{
bool error= 1;
int error= -1;
bool needs_to_be_stored= 0;
longlong org_reserved_until= reserved_until;
longlong org_next_free_value= next_free_value;
@ -788,13 +788,13 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round,
next_val= increment_value(next_val);
if (round > next_round)
goto end;
goto end; // error = -1
if (round == next_round)
{
if (real_increment > 0 ?
next_val < next_free_value :
next_val > next_free_value)
goto end;
goto end; // error = -1
if (next_val == next_free_value)
{
error= 0;
@ -802,7 +802,13 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round,
}
}
else if (cycle == 0)
goto end; // round < next_round && no cycles
{
// round < next_round && no cycles, which is impossible
my_error(ER_SEQUENCE_RUN_OUT, MYF(0), table->s->db.str,
table->s->table_name.str);
error= 1;
goto end;
}
else
needs_to_be_stored= 1;
@ -819,6 +825,7 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round,
reserved_until= org_reserved_until;
next_free_value= org_next_free_value;
round= org_round;
error= 1;
goto end;
}
}