Skip to content
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

Improve efficiency of readonly transactions by reusing the same read ts #2604

Merged
merged 4 commits into from
Sep 20, 2018

Conversation

manishrjain
Copy link
Contributor

@manishrjain manishrjain commented Sep 20, 2018

Currently, every transaction gets a new timestamp from Zero, which then has to propagate the allocated timestamp to every Alpha, so that it knows when to service that transaction. It would apply all the updates up until that ts, so the txn always returns consistent results.

If a user is only doing read-only transactions, then this system causes a lot of unnecessary work, because each txn gets a new ts from Zero. This changes that by allocating a new read-only timestamp, which can be reused across many read-only transactions, if no RW txns are going on in the system. This speeds up reads, because it avoids the wait for ts propagation from Zero to Alpha leader to followers.


This change is Reviewable

…d make readonly queries more efficient by utilizing the same readonly timestamp, instead of having to lease and propagate a new MaxAssigned each time.
…Also, avoid streaming MaxAssigned if nothing new was assigned.
@manishrjain manishrjain merged commit fe7b749 into master Sep 20, 2018
@manishrjain manishrjain deleted the mrjn/readonly-txns branch September 20, 2018 02:31
dna2github pushed a commit to dna2fork/dgraph that referenced this pull request Jul 19, 2019
…ts (dgraph-io#2604)

Currently, every transaction gets a new timestamp from Zero, which then has to propagate the allocated timestamp to every Alpha, so that it knows when to service that transaction. It would apply all the updates up until that ts, so the txn always returns consistent results.

If a user is only doing read-only transactions, then this system causes a lot of unnecessary work, because each txn gets a new ts from Zero. This PR changes that by allocating a new read-only timestamp, which can be reused across many read-only transactions, if no RW txns are going on in the system. This speeds up reads, because it avoids the wait for ts propagation from Zero to Alpha leader to followers.

Commits:

* Logic to retrieve read only timestamps from Dgraph cluster. This would make readonly queries more efficient by utilizing the same readonly timestamp, instead of having to lease and propagate a new MaxAssigned each time.

* Working code for ReadOnly Txns.

* Add a test to ensure that all read-only txns get the same timestamp. Also, avoid streaming MaxAssigned if nothing new was assigned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant