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

Question: Multiple iterators on a read-write transaction. #981

Closed
elliotcourant opened this issue Aug 13, 2019 · 3 comments · Fixed by #1286
Closed

Question: Multiple iterators on a read-write transaction. #981

elliotcourant opened this issue Aug 13, 2019 · 3 comments · Fixed by #1286

Comments

@elliotcourant
Copy link
Contributor

elliotcourant commented Aug 13, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.6 darwin/amd64

What version of Badger are you using?

master @ 74ed6da

What is the limiting factor of the transaction or iterator object being thread-safe? Is it the pending writes map/iterator that isn't safe if there are multiple iterators at the same time as data being written?

I'm trying to run two iterators on a transaction after some entries have been written, but while the two iterators are active no writes will occur. If the limiting factor is writes cannot happen while multiple iterators are active would it be reasonable to simply restrict writes until iterators are deallocated?

Sorry if I'm misunderstanding the issue; trying to understand the workings with that object to better approach my problem.

Also sorry if this is not the correct venue for this question. I'm happy to move it if it is.

@ashish-goswami
Copy link
Contributor

@elliotcourant Currently limiting factor is pending write map in transaction. It is not thread safe.
That's the reason, you cannot have multiple iterators in RW transaction.
I am not following the second part you asked. Are you trying to run two iterators in RW transaction? Also are entries are written in same transaction?

@elliotcourant
Copy link
Contributor Author

I am trying to run two iterators but I don't think I will get the performance benefit that I thought that I would. I was mostly just curious about what the limiting factor was. Thank you very much!

@manishrjain
Copy link
Contributor

We could easily make the txn run iterators concurrently. Thread unsafe was just seemed simple enough for the utility when originally written.

elliotcourant added a commit to elliotcourant/badger that referenced this issue Mar 31, 2020
This adds support for multiple iterators during a read-write transaction. But iterators created in a read-write transaction will only be able to see writes that were performed before the iterator was created. Any writes that occur after the iterator is created will be invisible to the iterator.

This references an issue I opened previously: hypermodeinc#981
@elliotcourant elliotcourant reopened this Mar 31, 2020
elliotcourant added a commit to elliotcourant/badger that referenced this issue Mar 31, 2020
This adds support for multiple iterators during a read-write transaction. But iterators created in a read-write transaction will only be able to see writes that were performed before the iterator was created. Any writes that occur after the iterator is created will be invisible to the iterator.

This references an issue I opened previously: hypermodeinc#981
elliotcourant added a commit to elliotcourant/badger that referenced this issue Apr 24, 2020
This adds support for multiple iterators during a read-write transaction. But iterators created in a read-write
transaction will only be able to see writes that were performed before the iterator was created. Any writes that occur
after the iterator is created will be invisible to the iterator.

This references an issue I opened previously: hypermodeinc#981

Added a test case for using multiple concurrent iterators when inside a
read-write transaction. Added a mutex around the reads array on the
transaction to make sure that it is thread safe when it is being
modified by potentially concurrent iterators.
elliotcourant added a commit to elliotcourant/badger that referenced this issue Apr 24, 2020
This adds support for multiple iterators during a read-write transaction. But iterators created in a read-write
transaction will only be able to see writes that were performed before the iterator was created. Any writes that occur
after the iterator is created will be invisible to the iterator.

This references an issue I opened previously: hypermodeinc#981

Added a test case for using multiple concurrent iterators when inside a
read-write transaction. Added a mutex around the reads array on the
transaction to make sure that it is thread safe when it is being
modified by potentially concurrent iterators.
elliotcourant added a commit to elliotcourant/badger that referenced this issue Apr 24, 2020
This adds support for multiple iterators during a read-write transaction. But iterators created in a read-write
transaction will only be able to see writes that were performed before the iterator was created. Any writes that occur
after the iterator is created will be invisible to the iterator.

This references an issue I opened previously: hypermodeinc#981

Added a test case for using multiple concurrent iterators when inside a
read-write transaction. Added a mutex around the reads array on the
transaction to make sure that it is thread safe when it is being
modified by potentially concurrent iterators.
@stale stale bot added the status/stale The issue hasn't had activity for a while and it's marked for closing. label Apr 30, 2020
@stale stale bot closed this as completed May 7, 2020
@jarifibrahim jarifibrahim removed the status/stale The issue hasn't had activity for a while and it's marked for closing. label May 13, 2020
@hypermodeinc hypermodeinc deleted a comment from stale bot May 13, 2020
@hypermodeinc hypermodeinc deleted a comment from stale bot May 13, 2020
@jarifibrahim jarifibrahim reopened this May 13, 2020
jarifibrahim pushed a commit that referenced this issue May 13, 2020
This adds support for multiple iterators during a read-write transaction. The
iterators created in a read-write transaction will only be able to see writes
that were performed before the iterator was created. Any writes that occur
after the iterator is created will be invisible to the iterator.

Fixes #981
manishrjain pushed a commit to outcaste-io/outserv that referenced this issue Jul 6, 2022
This adds support for multiple iterators during a read-write transaction. The
iterators created in a read-write transaction will only be able to see writes
that were performed before the iterator was created. Any writes that occur
after the iterator is created will be invisible to the iterator.

Fixes hypermodeinc/badger#981
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants