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

PubSub sometimes failing #52

Closed
richardschneider opened this issue Jan 2, 2018 · 5 comments
Closed

PubSub sometimes failing #52

richardschneider opened this issue Jan 2, 2018 · 5 comments

Comments

@richardschneider
Copy link

richardschneider commented Jan 2, 2018

C# test and JS test are intermittently failing. Both are publishing multiple messages and then counting the subscribed messages.

It appears that some published messages are not being relayed to the subscribed channels. In the C# test both publisher and subscriber are on the same peer.

NOTE: these tests are running on Windows. This was first detected in ipfs-inactive/js-ipfs-http-client#648

@richardschneider
Copy link
Author

this code looks suspicious

binary.BigEndian.PutUint64(seqno, uint64(time.Now().UnixNano()))

A duplicate sequence number can be produced when a second publish event is received within the resolution of the clock. If this occurs, then the second publish event will not be relayed.

On Windows, the default clock resolution is 15.6 ms, but it appears go changes it to 1ms. This is more that adequate to produce a duplicate sequence number.

@Stebalien
Copy link
Member

Yes, that looks like a bug. We should just use an atomic counter (maybe start at the current unix time to better handle restarts).

@richardschneider
Copy link
Author

@Stebalien Or maybe concatenating the time with an atomic counter.

@Stebalien
Copy link
Member

@richardschneider good point (I thought we had to try to fit this into a 64bit int but apparently not).

@vyzo
Copy link
Collaborator

vyzo commented Jan 3, 2018

Yeah, the 1ms resolution is not enough for real-time or bursty applications; definitely a bug.

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

No branches or pull requests

3 participants