Skip to content
Snippets Groups Projects
user avatar
Vladislav Shpilevoy authored
The function replica_check_id() is called on any change in
_cluster: insert, delete, update. It was supposed to check if the
replica ID is valid - not nil, not out of range (VCLOCK_MAX).

But it was also raising an error when the ID matched this
instance's ID unless the instance was joining. That happened even
if a _cluster tuple was updated without changing the ID at all.
For example, if one would just do
_cluster:replace(_cluster:get(box.info.id)).

That was a surprising side effect of the ID checker which blocked
next patches. The next commits are going to introduce a new field
in _cluster (replica name) which will be mutable. Such behaviour
of replica_check_id() wouldn't allow to update even that new
field.

Better do the check in the only place where the mutation can
happen - on deletion. Since replica ID is a primary key in
_cluster, it can't be updated there. Only inserted or deleted.

Needed for #5029

NO_DOC=bugfix and refactoring
NO_CHANGELOG=couldn't happen unless user touched _cluster in a
    weird way
NO_TEST=covered by next commits, too insignificant for an own test
cb8f4715
History
Name Last commit Last update