-
Notifications
You must be signed in to change notification settings - Fork 193
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
tests: add a test of idempotency of same txn storage #1511
Conversation
@balegas This adds the aforementioned test. As to whether we should avoid writing at all in case of duplication, I think we can loop back to that question later because under current implementations it's not necessary. If our storage engine becomes actually append-log, then it might become an important idea |
Do you mind leaving a comment in the code noting that the way we write to storage actually implies idempotency and why it is required? I suppose this is remains true for an in-memory approach |
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.
The code looks good but I have some thoughts on whether it addresses the issue.
Right now the replication stream is only responsible for saving incoming transactions to log storage. But we've already had discussions about streaming transactions in parallel with persisting them to log storage in some cases. As the system evolves, at some point we may replace the current transaction_received
callback passed to ReplicationClient
with another function potentially from another module, side-stepping the test that only verifies the behaviour of ShapeLogCollector.
I think we can potentially address the duplicate transaction processing problem at the source, i.e. by having information inside ReplicationClient about which lsn it processed last. It's just that implementing this approach requires some design work first.
packages/sync-service/test/electric/replication/shape_log_collector_test.exs
Outdated
Show resolved
Hide resolved
packages/sync-service/test/electric/shape_cache/storage_implementations_test.exs
Show resolved
Hide resolved
…ector_test.exs Co-authored-by: Oleksii Sholik <oleksii@sholik.dev>
I see this being merged and the original issue being closed, but I feel that the PR misses the point of the issue. I don't think we need to do the engineering ahead of switching implementations and we might actually touch that code when we do #1506. So, I'm happy addressing the issue at the source there. However, I strongly think that we need to document in code the implicit property. |
I have filed a new issue specifically for addressing the storage of replication state for the purpose of detecting repeat transactions without involving the shape storage subsystem - #1515. |
@balegas I've added a storage-level test explicitly for this reason, so that it's less tied to the shape log collector implementation. If someone adds an append-only storage, I would assume they would look at the failing test and question the assumption explicitly stated there. Do you feel like that's not enough? |
Closes #1505 --------- Co-authored-by: Oleksii Sholik <oleksii@sholik.dev>
Closes #1505