-
Notifications
You must be signed in to change notification settings - Fork 7
decide what if anything to do about the difference in memstore/idbstore apis #62
Comments
EEP. This is the one that gives me pause. Landing #58 doesn't seem like it completely brings idbstore into alignment with memstore in that case. |
I'm not clearly understanding the difference between memstore and idb impls so it's hard to comment. However:
In order to have an opinion on which of these paths to take I need to understand the diff between the two APIs better. Does somebody understand it clearly yet or do we need a project to understand that? |
https://github.com/rocicorp/repc/pull/58/files#diff-e83d091a2db9fc52230899a70d97e3a4R42 explains the main thing. The other q is whether browsers actually utilize this loophole https://github.com/rocicorp/repc/pull/58/files#diff-e83d091a2db9fc52230899a70d97e3a4R47, if so we potentially suffer some hit to concurrency. what else are you after?
Note that the inability to enforce mutual exclusion at the idbstore level does not affect correctness. Per the long comment linked to, idb is enforcing the constraints under the hood, just not visibly to us. Adding the rwlock to idbstore makes it work like memstore wrt a single page. It doesn't work like memstore across page w/o a weblocky thing, but that does not affect correctness. |
w3c/IndexedDB#253 clearly suggests that today, all browsers enforce that readwrite transactions cannot be started while readonly ones are still running, and this is suggested to be added to the spec. As such, I think @phritz's suggestion to enforce that around our IdbStore is appropriate, and support that being enforced with a RwLock. Thanks for documenting all of this detail @phritz. |
@aboodman i would like a thumbs up for you on this. Nate thinks it's a fine idea. Let's not overthink this. In essence all we are talking about is a change in the way the api works, simplified pseudo code:
The proposal is to make the idbstore work like the memstore, that is, have it asynchronously wait until there are no exclusive txs outstanding before returning a new tx. |
Right but it won't do that across tabs right? Is the main reason to do this so that we can unit test? I guess, I get it but I'm having trouble wrapping my head around what the result of the discrepancy across tabs is. |
In any case: 👍 to not block. |
correct
the reasons are 1) so we have a clear mental model that is consistent across both idbstore and memstore (no mental gymnastics to keep two ways things work in your head) and 2) so that when we write tests with memstore they are meaningful (because idbstore works the same way).
if a mutually exclusive tx is open in another tab then in this tab a call to open a read or write tx will return immediately making you think the tx is running when in fact it hasn't started yet. |
On Fri, Jul 24, 2020 at 1:56 PM Phritz ***@***.***> wrote:
Right but it won't do that across tabs right?
correct
Is the main reason to do this so that we can unit test?
the reasons are 1) so we have a clear mental model that is consistent
across both idbstore and memstore (no mental gymnastics to keep two ways
things work in your head) and 2) so that when we write tests with memstore
they are meaningful (because idbstore works the same way).
I guess, I get it but I'm having trouble wrapping my head around what the
result of the discrepancy across tabs is.
if a mutually exclusive tx is open in another tab then in this tab a call
to open a read or write tx will return immediately making you think the tx
is running when in fact it hasn't started yet.
sgtm
|
implemented by #58 |
This issue attempts to summarize this meandering discussion from slack re mem/idbstore and locking: https://rocicorp.slack.com/archives/CMQQ9EDML/p1595449965291900
How we got to be talking about this:
I suspect we can all agree that memstore and idbstore should, if possible, work the same way for sanity's sake and so our tests are most useful. I think the question is whether to make idbstore work like memstore as in pr 58 above, or to go the other way and make memstore work like idbstore. We are still discovering aspects of this we haven't thought of so please chime in with anything you see. Having said that, here's what I currently see:
Pros for making idbstore use the rwlock:
Cons for making idbstore use the rwlock:
potentially less concurrency if idb can safely run read txs while running write txsEdit: @whiten found that no browsers do this any moreProposal: this is not the most important thing right now, or even an important thing right now, so let's make idbstore work like memstore by merging PR 58 above so we have a nice simple mental model. we can file issues to track the potential negatives and reconsider in the future.
@whiten did i miss anything?
cc @arv @aboodman
The text was updated successfully, but these errors were encountered: