-
Notifications
You must be signed in to change notification settings - Fork 387
Provide a method to get instance vclock after all writes in progress are finished #10142
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
Comments
See also #9937. |
Will it be possible to use this to read committed data even if we don’t enable MVCC ? Now we use something like this as a workround: box.begin() |
That's a clever hack you have! I haven't thought of that myself.
I think not. At least not with the current implementation.
Having a ton of transactions all doing Of course we might redesign |
I don’t need it inside the transaction, it’s enough to understand that the writes that were in the queue have been completed, this will indicate that any previous operations do not read dirty data. .. if I'm not mistaken..
my hack assumes that there will always be a dummy write, but if there is nothing in the queue it don't have to wait for anything at all, this should immediately indicate that any previous readings were not dirty. My issue is precisely to more effectively handle situations when it is known in advance that all writing transactions have already been completed. For example, I could extend my hack and make a counter of open and completed transactions, increase it at the beginning of the transaction and decrease it in the oncommit/rollback trigger, in this case it need to make a dummy write ops only if the counter is not zero. .. it seems like it should work, again, unless I'm missing something.. |
Ok, I see. It seems you could do the following then:
It seems this will stay correct as long as you do |
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to access C `wal_sync` function needed for syncronisation between old and new masters and any other situations when user need consistenct vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to access C `wal_sync` function needed for syncronisation between old and new masters and any other situations when user need consistenct vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to wait until all submitted writes are successfully flushed to the disk. If write failed it throws an error. It is primarily needed for syncronisation between old and new masters or actually any other situations when user need consistent vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to wait until all submitted writes are successfully flushed to the disk. If write failed it throws an error. It is primarily needed for syncronisation between old and new masters or actually any other situations when user need consistent vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to wait until all submitted writes are successfully flushed to the disk. If write failed it throws an error. It is primarily needed for syncronisation between old and new masters or actually any other situations when user need consistent vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to wait until all submitted writes are successfully flushed to the disk. If write fails it throws an error. It is primarily needed for synchronisation between old and new masters or actually any other situations when user need consistent vclock between instances. Fixes tarantool#10142
@TarantoolBot document Title: `box.ctl.wal_sync` can be used in lua to wait write flush Now one can use `box.ctl.wal_sync()` to wait until all submitted writes are successfully flushed to the disk. If write fails it throws an error. After the function is executed one may reliably use box.info.vclock for comparisons when choosing a new master Fixes tarantool#10142
It's common practice to implement master switch via the following steps:
box.cfg{read_only = true}
on the old masterbox.info.lsn
)lsn
on the new desired masterbox.cfg{read_only = false}
on the new masterThese steps are supposed to guarantee that in case both old and new masters are alive the switch happens only after the new master receives everything that was written by the old master. But there's a problem:
box.cfg{read_only = true}
only affects the transactions which aren't yet sent to WAL. IOW, settingbox.cfg{read_only = true}
doesn't guarantee thatbox.info.lsn
will stop growing immediately. It might still need some time to reflect the last writes.Reproducer:
Let's provide a
box.ctl
method to sync WAL. For example,box.ctl.wal_sync()
. It'll issue the Cwal_sync
method and make sure that all the ongoing writes are finished. With this implementing failover correctly will become possible: the user will have to performbox.ctl.wal_sync()
before rememberingbox.info.lsn
.The text was updated successfully, but these errors were encountered: