-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Linearizable reads/writes #1344
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
So, linearizability is implemented (albeit under-tested, and the simplest possible implementation as described). In the branch sam/new1344. One thing that isn't implemented, though is the question, what should the UI be? How should the user specify a linearizable read vs. a non-linearizable one? Option 1: an out-of-band flag. |
All reads should be linearizable for now. If performance becomes an issue, we'll solve for it when it does. |
I'm getting 14 second reads with a simple curl query while running dgraphloader. Running the Raft ReadIndex operation is quick, but then it takes about 12 seconds between getting a linearizable read index and for |
This is because we're using goroutines for each mutation which get scheduled whenever they do. @janardhan1993 is working on a smart scheduler which can prioritize mutations in a roughly FIFO order. That should reduce the applied latency. But, great to hear read linearizability is working! PR? |
To minimise the latency, i guess we need to schedule all the mtuations which came after read request only when the applied watermark catches up. |
Linearizability won't be fully working until #1345 (for which a basic fix has just been implemented) because it does in fact trigger that scenario sometimes. |
#1345 was fixed, so this can be closed. |
This commit brings the following changes from badger c45d966 Fix assert in background compression and encryption. (#1366) 14386ac GC: Consider size of value while rewriting (#1357) b2267c2 Restore: Account for value size as well (#1358) b762832 Tests: Do not leave behind state goroutines (#1349) 056d859 Support disabling conflict detection (#1344) fd89894 Compaction: Expired keys and delete markers are never purged (#1354) 543f353 Fix build on golang tip (#1355) a7e239e StreamWriter: Close head writer (#1347) da80eb9 Iterator: Always add key to txn.reads (#1328) 7e19cac Add immudb to the project list (#1341) 079f5ae DefaultOptions: Set KeepL0InMemory to false (#1345)
This commit brings the following changes from badger ``` c45d966 Fix assert in background compression and encryption. (#1366) 14386ac GC: Consider size of value while rewriting (#1357) b2267c2 Restore: Account for value size as well (#1358) b762832 Tests: Do not leave behind state goroutines (#1349) 056d859 Support disabling conflict detection (#1344) fd89894 Compaction: Expired keys and delete markers are never purged (#1354) 543f353 Fix build on golang tip (#1355) a7e239e StreamWriter: Close head writer (#1347) da80eb9 Iterator: Always add key to txn.reads (#1328) 7e19cac Add immudb to the project list (#1341) 079f5ae DefaultOptions: Set KeepL0InMemory to false (#1345) ```
(We didn't have an issue for this.) The feature we want is for read behavior to be linearizable, instead of happily reading outdated data.
The short of it is, we're going to use etcd/raft's ReadIndex functionality. To avoid spamming Raft groups' leaders with MsgReadIndex messages, each follower node will only make one in-flight request at a time. We'll do this from whatever node serves our Raft group.
That's the most basic version -- we could get more clever about how we do ReadIndex in the future to reduce latency. We could allow multiple in-flight requests (and take care not to let them bunch up).
We could send our requests from other machines to avoid extra network hops. Some descriptions of alternatives are here: https://discuss.dgraph.io/t/linearizability/1683/3
We will also need to change the watermark implementation to not use sleep.
The text was updated successfully, but these errors were encountered: