-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Introduce MongoDB sharding rules to Client-wide collections #768
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #768 +/- ##
=======================================
Coverage 50.73% 50.73%
=======================================
Files 70 70
Lines 10234 10274 +40
=======================================
+ Hits 5192 5213 +21
- Misses 4517 4536 +19
Partials 525 525 ☔ View full report in Codecov by Sentry. |
This commit introduces MongoDB sharding rules to documents and document-wide collections (e.g. Changes, SyncedSync, Snapshots). Changes: - Introduce RefKey to represent ID and shard key together instead of ID. - Change the reference key of Users from _id to username. - Introduce encoders for types.ID, time.ActorID and ClientDocInfo to MongoDB.
f8f61f2
to
2788be4
Compare
2788be4
to
8d00c78
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This commit introduces MongoDB sharding rules to
clients
and client-wide collections (e.g.syncedSeqs
).Some fields continue to use
client_id
instead of(client_key, client_id)
:actor_id
in thechanges
andsyncedSeqs
collectionsowner
in thedocuments
collectionpublisher
inDocEvent
of thepubsub
packageCurrently, Yorkie utilizes the
objectID
in MongoDB as aclient_id
.According to the official MongoDB post, the
objectID
is composed of 12 bytes (TimeStamp(4 bytes) + MachineId(3 bytes) + ProcessId(2 bytes) + Counter(3 bytes)), making it unlikely to be duplicated in practical use cases.Furthermore, the chances of
actor_id
andpublisher
in a single document being duplicated are even lower.Considering Yorkie isn't currently expected to exceed the practical use cases, maintaining the
client_id
reference key in the aforementioned concerns seems reasonable.In addition, the
client_key
currently doesn't have any use case, including theowner
in thedocuments
collection. It seems possible to remove theclient_key
field fromclients
and client-wide collections.Then, I believe we can use
client_id
as a shard key instead (with an unique constraint), eliminating the risk of duplicate IDs inclient_id
.Moreover, there are alternatives for handling duplicate
client_id
s:actor_id
as a combination ofclient_key
andclient_id
Which issue(s) this PR fixes:
Addresses #673
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist: