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

tests: add a test of idempotency of same txn storage #1511

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

icehaunter
Copy link
Contributor

Closes #1505

@icehaunter icehaunter requested a review from alco August 12, 2024 12:10
@balegas
Copy link
Contributor

balegas commented Aug 12, 2024

@icehaunter see #1505 (comment)

@icehaunter
Copy link
Contributor Author

@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

@balegas
Copy link
Contributor

balegas commented Aug 12, 2024

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

Copy link
Member

@alco alco left a 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.

…ector_test.exs

Co-authored-by: Oleksii Sholik <oleksii@sholik.dev>
@icehaunter icehaunter merged commit 3135678 into main Aug 12, 2024
20 checks passed
@icehaunter icehaunter deleted the ilia/duplicate-transaction-validation branch August 12, 2024 15:05
@balegas
Copy link
Contributor

balegas commented Aug 12, 2024

I see this being merged and the original issue being closed, but I feel that the PR misses the point of the issue.
Ideally the test should cover the any implementation rather than a specific one, but if it doesn't we need to document the assumption, because this implicit property is required for the correctness of the system. I think that is helpful that the test covers any changes that people might do to the current implementation, but I feel that documentation is needed for someone that is making a new storage implementation.

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.

@alco
Copy link
Member

alco commented Aug 12, 2024

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.

@icehaunter
Copy link
Contributor Author

@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?

KyleAMathews pushed a commit that referenced this pull request Nov 1, 2024
Closes #1505

---------

Co-authored-by: Oleksii Sholik <oleksii@sholik.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write a test that verifies the idempotency of processing the same transaction more than once
3 participants