-
Notifications
You must be signed in to change notification settings - Fork 9
Add Storage Subscription Capability Interfaces #1386
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
Conversation
| // We also update heap so it holds latest record | ||
| if (fact) { | ||
| this.heap.merge([fact], Replica.update); | ||
| this.heap.merge([fact], Replica.put); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unlikely that we were missing the fact in our heap, so update would usually have the same behavior, but this is more correct (put).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually encountered it in one of the added tests.
| const freshFacts = revisions.filter((revision) => | ||
| this.pendingNurseryChanges.get(toKey(revision))?.size ?? 0 === 0 | ||
| ); | ||
| this.nursery.merge(freshFacts, Nursery.delete); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor issue going from delete on freshFacts to evict on all facts here.
Imagine a counter, where the user presses +,+,-
- send 1 -- counter shows 1
- recieve 1
- send 2 -- counter shows 2
- send 3 -- counter shows 3
- send 2 -- counter shows 2
- receive 2 (the first one)
- evict: removes from nursery, since they are the same - counter still shows 2
- freshFacts/delete: doesn't remove from nursery, since it's not fresh - counter still shows 2
- receive 3
- evict: thinks it's new - counter goes back to 3 (incorrect)
- freshFacts/delete: doesn't remove from nursery, since it's not fresh - counter still shows 2
- receive 2 (second one)
- evict: thinks it's new - counter goes back to 2 (correct now)
- freshFacts/delete: removes from nursery, since there's no longer any pending - counter still shows 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evict: removes from nursery, since they are the same - counter still shows 2
It will not because cause will be different so equality check will not pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have a test for this scenario though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does still have an issue with two clients and rapid clicks. The evict version leads to a conflict storm where we go up and down in a loop, while the delete version stabilizes.
I'll investigate more to determine why.
Define interfaces per https://linear.app/common-tools/issue/CT-561
Summary by cubic
Added interfaces to support storage subscription capabilities, allowing clients to subscribe to storage notifications for commit, revert, load, pull, and sync events as required by Linear issue CT-561. Also updated related type names for consistency.