-
Notifications
You must be signed in to change notification settings - Fork 102
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
client/dex: BookUpdate notification races #2203
client/dex: BookUpdate notification races #2203
Conversation
client/core/bookie.go
Outdated
// newFeed gets a new *bookFeed and cancels the close timer. feed must be called | ||
// with the bookie.mtx locked. The feed is primed with the provided *BookUpdate. | ||
// newFeed gets a new *bookFeed and cancels the close timer. newFeed must be called | ||
// with the bookie.feedsMtx locked. The feed is primed with the provided *BookUpdate. | ||
func (b *bookie) newFeed(u *BookUpdate) *bookFeed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems after #1208 this feed must be called with the bookie.mtx locked
part is no longer correct/relevant ?
I changed the comment phrasing to reflect latest renames but since bookie.feedsMtx
is locked below and I don't see it being locked before outer func calls newFeed
suggests to me 1) comment is no longer relevant 2) locking itself is fine; So we should probably erase this comment part completely now, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're committing the cardinal sin of closing the channels in a goroutine that is not the sender.
I think the comment may be alluding to the added duties of the mutex there, but not sure. I feel like the comment may have missed the with "calling" when it's meant "accessed" (referring to channel as feed
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comments according to my current understanding (based on relevant commit here d11f1ce).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I've figured it out, added more comments on what I think is going on there: 33fd0a0, not quite in that commit - just see the latest PR diff instead.
Just as an example, handleBookOrderMsg
is one place where we can drop order book update meant to be relayed to bookie.feeds
if we release dc.booksMtx
before the feed was properly created (and relayed initial "book" message) with bookie.newFeed
.
And If I'm not missing something we can probably just prepare bookie
locally first and only then grab dc.booksMtx
to insert it into dc.books
map ? I'd want to look into that some more.
note, we only ever use 1 feed per bookie right now
Ah well, I got that ^ part wrong; so we need to lock dc.booksMtx
to prevent initialising same bookie
twice when in fact what we want is to have 1 bookie
and 2 feeds in such case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm digging a bit deeper though, more stuff is coming out. Squashed existing commits and put PR in Draft for now.
36d152e
to
6b0e77d
Compare
…updates coming from the server are applied when maket resubscribe happens after connection with the server broke.
Once again, a norwnd PR that does nothing. You're effectively only undoing the shit I already told you not to do in your last PR. You pull this shit again, and I'll revoke your contractor request. Stop wasting our time. |
Well, it does fix these races for me:
and this one too
basically proving my statement in comments:
|
Resolves #2188. Addresses the rest of the things discussed.