New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to resolve the replication conflict of the operation type is 'insert.' #4503
Comments
That is correct. You can't. The primary key stays the same, and the operation type is still INSERT after your trigger, and the old tuple still exists. So there is no reason why this INSERT should not fail. |
But. You can change the new tuple, and it will turn the operation into REPLACE. Try this:
|
Sorry, closed accidentally. |
Given there is a workaround, this should be turned into a documentation issue. |
What if changing INSERT into REPLACE is not acceptable? Ex., I want to skip only duplicate records but still get an error for any other conflicts like this: space:before_replace(function(old, new)
if old and new and utils.tuples_equal(old, new) then
return old
end
return new
end) UPD. It appears that this code works as intended, and the problem was in the inserted data. |
OK, so what is the issue then? You can return old, new, or an entirely new tuple - the trigger may behave differently depending on data it receives. For this and many other cases we need to add access to transaction state through Lua API. It's a matter of adding a few Lua bindings, so is more like a feature, not a bug. But given it's pretty safe to add these bindings, I think we can add them to 1.10 as well. The bindings should provide access not only to the current operation type, but LSN and server id. |
Tarantool version:
1.10.3-80
OS version:
MacOS 10.14.6
Bug description:
I try to resolve the replication conflict between two tuples with before_replace trigger. Which looks like this:
If an operation type is 'replace' then this trigger works correct, but if an operation type is 'insert', I receive the error:
So I don't know how to resolve this conflict. 🤷♂
Steps to reproduce:
On master instance:
On replica instance:
On master instance:
The text was updated successfully, but these errors were encountered: