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

Attempt to fix realtime links #152

Merged
merged 1 commit into from Jul 6, 2016
Merged

Attempt to fix realtime links #152

merged 1 commit into from Jul 6, 2016

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Jul 5, 2016

No description provided.

Make sure that _value added to msg is kept for when it is needed
@dominictarr
Copy link
Contributor

what does this fix?

_value is used so that live streams can emit immediately without a lookup.
https://github.com/ssbc/secure-scuttlebutt/blob/dc1c1f8a2000ba622881cb68de049541529eebe0/index.js#L479-L480

Which prevents a race condition in other places... though, I think that was before pull-live which is a better approach in general, so maybe that is now obsolete?

@clehner
Copy link
Contributor Author

clehner commented Jul 6, 2016

It is to fix NotFoundError being emitted from ssb.links, discussed in %rBu56IqW1RopjM7yOQUI3ckPjVC36b14ax8rLei2jVM=.sha256

_value isn't actually being used until this line is added:
dc1c1f8#diff-168726dbe96b3ce427e7fedce31bb0bcR457

I see db.links uses pull-live but I don't see how that should fix the race. I think what is happening is that before a message is added to the db, the pre hook function (L74) runs, passes a link index op synchronously through realtime(kv) (L82) to the pipeline in db.links (L499), to lookupLinks which calls db.get(op.key, ...) (L481). Trying to get the new message fails because the pre hook function hasn't returned yet and so the message hasn't yet been added.

@dominictarr dominictarr merged commit dc1c1f8 into master Jul 6, 2016
@dominictarr
Copy link
Contributor

now i remember. at first, i implemented real time views by just creating a live stream of the index,
then mapping that through the lookup. but this meant that realtime view was always delayed (because it would do a get.

but the new code just does the realtime part by filtering db.post(..) so this should now be unnecessary.

merged into 15.2.4

@clehner clehner deleted the links-race branch July 6, 2016 14:44
@clehner clehner changed the title msg Attempt to fix realtime links Jul 6, 2016
@clehner
Copy link
Contributor Author

clehner commented Jul 6, 2016

I just realized that the pull request message that I wrote for this wasn't published, because I used a wrong command-line flag (-m msg instead of -F msg) to the hub command. Sorry about that. Anyway, if the errors I was seeing persist, I will revisit this and maybe try to write a test case.

@dominictarr
Copy link
Contributor

ah got it

@clehner clehner mentioned this pull request Jul 10, 2016
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.

None yet

2 participants