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

Improve Peer Awareness's metadata to be updatable #181

Closed
wants to merge 6 commits into from

Conversation

dc7303
Copy link
Member

@dc7303 dc7303 commented Apr 24, 2021

What this PR does / why we need it:
Added UpdateMetadata API to update the client's metadata.

Which issue(s) this PR fixes:

Fixes #153

Special notes for your reviewer:
If the added API design is ok, I will also work on yorkie-js-sdk. I'll add a How to use? section in the design document later.

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

  • Added relevant tests or not required
  • Didn't break anything

dc7303 added 3 commits April 24, 2021 17:55
Yorkie should be able to update the client's metadata and notify other
clients.
@dc7303 dc7303 self-assigned this Apr 24, 2021
@ppeeou ppeeou requested a review from a team April 24, 2021 12:35
@dc7303 dc7303 assigned hackerwins, mojosoeun and ppeeou and unassigned dc7303 Apr 25, 2021
@codecov
Copy link

codecov bot commented Apr 25, 2021

Codecov Report

Merging #181 (6c8869d) into main (c58df97) will decrease coverage by 0.71%.
The diff coverage is 29.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
- Coverage   61.76%   61.05%   -0.72%     
==========================================
  Files          38       38              
  Lines        3348     3423      +75     
==========================================
+ Hits         2068     2090      +22     
- Misses       1090     1143      +53     
  Partials      190      190              
Impacted Files Coverage Δ
api/converter/from_pb.go 66.75% <0.00%> (-0.35%) ⬇️
api/converter/to_pb.go 84.95% <0.00%> (-0.70%) ⬇️
client/client.go 7.51% <0.00%> (-0.62%) ⬇️
yorkie/rpc/server.go 49.07% <0.00%> (-5.53%) ⬇️
yorkie/backend/sync/memory/pubsub.go 97.46% <100.00%> (+0.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c58df97...6c8869d. Read the comment docs.

// UpdateMetadata updates metadata of subscriber.
func (s *Subscription) UpdateMetadata(subscriber types.Client) {
s.subscriber.Metadata = subscriber.Metadata
}
Copy link
Member

@ppeeou ppeeou Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be necessary to use mutex locks for this part 🤔??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to write test cases that modify the metadata at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ppeeou @hackerwins Thank you for your comment!

This is the reason why the method was not locked.
To access Subscription, you can access it through PubSub.subscriptionsMap. And since subscriptionsMap is private, I thought that PubSub's mutex would be sufficient. This is because all PubSub methods use the same mutex. As a result, it was determined that it is safe to call other PubSub methods at the same time.

At the same time, when modifying the metadata, it was confirmed that the order in which the metadata is updated and the order in which it is published does not match. The UpdateMetadata API has been improved so that can be locked by the client ID. (c92ff31)

@dc7303 dc7303 force-pushed the feat-update-metadata branch 2 times, most recently from 523c851 to c92ff31 Compare May 2, 2021 13:47
The order of publishing after calling PubSub.UpdateSubscriber in
UpdateMetadata should be synchronized. When requests from the same
client are requested at the same time, the final result can be matched.
@dc7303 dc7303 force-pushed the feat-update-metadata branch from c92ff31 to 6c8869d Compare May 5, 2021 14:19
@dc7303
Copy link
Member Author

dc7303 commented May 5, 2021

Is there any reason to use wg.Wait() here??🤔

Oh! My mistake. thank you for telling me :)

Copy link
Member

@ppeeou ppeeou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dc7303
Copy link
Member Author

dc7303 commented May 8, 2021

@hackerwins @ppeeou
Is it okay if I do PR on js-sdk as well?
It would be nice to test it together.

@hackerwins
Copy link
Member

When configuring the metadata without the logical clock, I am not sure that the problem will not occur when used to store the editor's cursor. I think it would be better to check and proceed further to see if the problem situation does not occur.

@hackerwins
Copy link
Member

I would like to do this work together after the distributed pubsub implementation.

@hackerwins hackerwins closed this May 20, 2021
@hackerwins hackerwins deleted the feat-update-metadata branch April 6, 2023 01:46
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.

Improve Peer Awareness's metadata to be updatable
4 participants