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

Don't wait while pushing #310

Merged
merged 1 commit into from
Apr 14, 2020
Merged

Don't wait while pushing #310

merged 1 commit into from
Apr 14, 2020

Conversation

sanderpick
Copy link
Member

Closes #309

Also pushes records added by AddRecord.

@sanderpick sanderpick requested a review from jsign April 14, 2020 20:19
@@ -386,8 +383,6 @@ func (s *server) pushRecord(ctx context.Context, id thread.ID, lid peer.ID, rec
if err = s.ps.Publish(ctx, id, req); err != nil {
log.Errorf("error publishing record: %s", err)
}

wg.Wait()
Copy link
Member Author

Choose a reason for hiding this comment

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

I can't remember why we waited here... probably out of an abundance of caution while developing.

return err
}
if err = n.store.SetHead(id, lg.ID, r.Cid()); err != nil {
if err = n.bus.SendWithTimeout(NewRecord(r, id, lg.ID), notifyTimeout); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Just flipping the order here. Seems safer to set the head before broadcasting.

if err = n.PutRecord(ctx, id, lid, rec); err != nil {
return err
}
return n.server.pushRecord(ctx, id, lid, rec)
Copy link
Member Author

Choose a reason for hiding this comment

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

Surely this must have been a bug... why not push out records from AddRecord as well as CreateRecord?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. Eventually, this can be different if we plan to batch pushes or similar, but not the case now.
SGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice yeah, good call

if err = n.PutRecord(ctx, id, lid, rec); err != nil {
return err
}
return n.server.pushRecord(ctx, id, lid, rec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. Eventually, this can be different if we plan to batch pushes or similar, but not the case now.
SGTM.

Signed-off-by: Sander Pick <[email protected]>
@sanderpick sanderpick merged commit 1ea8c06 into master Apr 14, 2020
@sanderpick sanderpick deleted the sander/push-no-wait branch April 14, 2020 21:39
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.

CreateRecords waits for push requests to be finished
2 participants