Closed kokodak closed 1 week ago
The recent changes introduce guard clauses in the FindChangeInfosBetweenServerSeqs
methods within the Client
and DB
structs, ensuring that the methods return early if the from
parameter exceeds the to
parameter. Additionally, new test cases have been added to validate the behavior of these methods, enhancing test coverage and ensuring consistency in server sequence values.
File Path | Change Summary |
---|---|
server/backend/database/mongo/client.go |
Added a guard clause in FindChangeInfosBetweenServerSeqs to return early if from > to , enhancing error handling. |
server/backend/database/memory/database.go |
Added a guard clause in FindChangeInfosBetweenServerSeqs to return early if from > to , enhancing error handling. |
server/backend/database/memory/database_test.go |
Introduced a new test case RunFindChangeInfosBetweenServerSeqsTest to validate behavior in database operations. |
server/backend/database/mongo/client_test.go |
Added a test case in TestClient for RunFindChangeInfosBetweenServerSeqsTest , verifying functionality. |
server/backend/database/testcases/testcases.go |
Added a new test function RunFindChangeInfosBetweenServerSeqsTest to check server sequence consistency. |
test/sharding/mongo_client_test.go |
Introduced a test case in TestClientWithShardedDB for RunFindChangeInfosBetweenServerSeqsTest , enhancing coverage. |
🐇 In the code where sequences flow,
A guard now stands to help us know.
With checks in place, we leap with glee,
Avoiding errors, as safe as can be!
Hooray for changes, let them unfold,
A tale of robustness, brave and bold! 🌟
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 51.14%. Comparing base (
3f4f5d3
) to head (1f7dbd3
). Report is 3 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I've written test code to cover what was mentioned in the PR text. But I'm worried that the test case for the database has too business-like terms in it.
Also, I'm not sure how to express in the test that the from > to
condition caused an early return. How do you think it should be expressed?
If you have any suggestions, please feel free to let me know.
@hackerwins Would you mind reviewing all the changes?
Could you explain me how to reproduce this scenario? I want to ensure there isn't another underlying issue.
Reproducing at the user level is very simple: you simply continue editing the document by yourself, without concurrent editing by other users.
Here is an example scenario:
A. Open the CodeMirror example of the JS SDK in a single browser B. Type 'abc' in the browser C. Check the server for queries from the corresponding editing client
In the above scenario, unnecessary queries were still occurring.
What this PR does / why we need it:
This PR modifies the
FindChangeInfosBetweenServerSeqs
method to avoid executing DB queries when thefrom
>to
. This change minimizes unnecessary database resource consumption, particularly in scenarios where the most recent document editor, User A, continues editing without any interference from other users (B, C, etc.).In such cases, in PushPull, User A's
Checkpoint.serverSeq
always equal to the server'sinitialServerSeq
(DocInfo.serverSeq), leading to a situation wherefrom > to
in theFindChangeInfosBetweenServerSeqs
method. By preventing the execution of a query under these circumstances, we can reduce the load on database resources.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Tests