-
Notifications
You must be signed in to change notification settings - Fork 580
refactor: staged writes in tagging stores #19476
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
1de3908 to
b30c796
Compare
nventuro
left a comment
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 looks like the capsule changes got here. Can you fix the branch?
benesjan
left a comment
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.
Most of it are nits and would approve if it were not for the sender_tagging_store test. Those seems to be quite messy.
All the naming suggestions are up for a debate. Just felt like plenty of it could be cuter.
BTW really like the whole staging approach you came up with. It's very elegant. Great job!
yarn-project/pxe/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/recipient_tagging_store.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/recipient_tagging_store.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/recipient_tagging_store.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/sender_tagging_store.test.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/sender_tagging_store.test.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/sender_tagging_store.test.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/sender_tagging_store.test.ts
Outdated
Show resolved
Hide resolved
yarn-project/pxe/src/storage/tagging_store/sender_tagging_store.test.ts
Outdated
Show resolved
Hide resolved
Probably a glitch while the capsule changes were squashed by CI, should be fine now |
Flakey Tests🤖 says: This CI run detected 3 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
benesjan
left a comment
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 all very cute now. Thanks
I think we might just be missing a few test cases but that's not a sufficient reason to block this so LGTM
| // Updating again with a higher value in the same job should work | ||
| // (if staged data wasn't cleared, it would still have the old value cached) |
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 are not using the same job below though so this seems out of place?
| expect(await taggingStore.getHighestAgedIndex(secret1, 'job2')).toBe(10); | ||
| await taggingStore.commit('job2'); | ||
|
|
||
| expect(await taggingStore.getHighestAgedIndex(secret1, 'job1')).toBe(10); |
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.
| expect(await taggingStore.getHighestAgedIndex(secret1, 'job1')).toBe(10); | |
| // Now we verify that we don't receive the data originally staged in job1 | |
| expect(await taggingStore.getHighestAgedIndex(secret1, 'job1')).toBe(10); |
Took me a bit to figure out how exactly this is testing the staged gets cleared.
| expect(await taggingStore.getHighestFinalizedIndex(secret2, 'job2')).toBe(6); | ||
| }); | ||
|
|
||
| it('clears staged data after commit', async () => { |
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 know it's annoying but given that aged and finalized indexes are stored completely separately we should have this test case (and some of the following) duplicated for both type of indexes.
| expect(await taggingStore.getHighestAgedIndex(secret1, 'job1')).toBe(10); | ||
| }); | ||
|
|
||
| it('does not affect other jobs when committing', async () => { |
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 one also should have the finalized index counterpart.
| }); | ||
| }); | ||
|
|
||
| describe('staged writes', () => { |
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 have 3 write operations on the public interface of the store:
- storePendingIndexes
- dropPendingIndexes
- finalizePendingIndexes
I think for each of these we want to test that:
- they are isolated between jobs,
- discarding works as expected,
- committing works as expected
So we seem to miss some test cases here. Or would you say it's unnecessery?
I mean we use the same private functions under the hood (e.g. #writePendingIndexes) so IDK it might be unnecessary.
Maybe the private functions should be on a separate class such that the higher level functionality could access only the functions that already handle the staging etc.?
That way we could test the staging directly and we would not deduce it works correctly from a higher level behavior.
But anyway think it's fine to merge this and do that in a followup PR if you agree.
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.
Discussed in Slack, to sum up:
-
we might end up refactoring and sharing some code between staged stores, but don't want to rush those abstractions
-
I'll merge this as is so I can propagate the latest changes in next to the branches that are downstream of this (in particular I want to get the NoteStore in soon because it's by far the trickiest). Then I'll do another round with specifics from code review, and I'll include adding the tests you mention here
Third part of the series started with #19445. This makes the stores related to tagging synchronization work based on staged writes.
e3c729d to
9619e78
Compare
Third part of the series started with #19445.
This makes the stores related to tagging synchronization work based on staged writes.