Description
There is concern that the memtx transaction mechanism is more complex than one can think after reading our docs. So, the expectation of a person trying to understand the transaction mechanism will broken on the reefs of reality again and again.
This is the excerpt from the tarantool’s English chat in Telegram (2018-02-13), the talk starts from an another topic:
Alec Larson: Does box.once create a fiber implicitly?
Konstantin Osipov: no
Alec Larson: So I should wrap with fiber.create before doing network calls?
Alec Larson: I'm assuming network calls don't implicitly yield unless inside a fiber. Is that right?
Georgy Kirichenko: A network operation does an yield or return Eagain in case if the operation cannot be processed immediately
Georgy Kirichenko: At this time a fiber creation does an yield
Dmitry Sharonov: it is not very good idea to do something that may fail (like network call) in box.once, because box.once is not reiterable
Dmitry Sharonov: if your network call fails - box.once still won't be executed again
Alec Larson: So doing fiber.yield() immediately after fiber.create() is pointless, right?
Georgy Kirichenko: Just after a fiber creation this created fiber is on cpu (with caller yield), this is limitation of the current fiber engine implementation. After a callee fiber yields caller fiber gets execution back, but this behavior isn't strictly specified and may be changed in future
Georgy Kirichenko: And there is no point to do fiber yield just after start because caller fiber is already yielded with all side effects (memtx transaction cancelation)
Alec Larson: That info should be in the docs somewhere. 🙂
Alexander Turenko: There is tricky detail: the transaction can be not aborted in some cases even after fiber.create(). I’m don’t know tarantool enough to point specific cases, but if speaking non-strictly:
- Before a first write in a memtx transaction.
- In case of 'simple' fiber function that can be optimized out to being executed within the callee stack… or like so.
Alexander Turenko: Such cases (as well as peculiarities of working within tarantool’s console) makes understanding of tarantool’s transactions on experiments harder than it should be. We need to create the 'memtx transaction in depth' section or article I guess. @lenkis, what do you think?
Elena Shebunyaeva: I agree
Elena Shebunyaeva: Could you please put this thread into a doc ticket?
Alexander Turenko: Of course.