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

Make the PinnerConnector great again #1086

Merged
merged 23 commits into from
Jun 10, 2019
Merged

Conversation

chmanie
Copy link
Member

@chmanie chmanie commented Apr 21, 2019

Description

This PR fixes a few things related to the pinner. Wow this took quite some time but I got it!

New stuff

  • It works again!
  • pinion and its dependencies (ipfsd, wss proxy) are now started on yarn dev

Changes 🏗

  • Updated orbit-db to commit 86b12cdd048ea7d5fa5a615adf6a2126d3084794 (shorter store names)
  • Updated pinion to commit f98c1bbf5103aa79b63a3370c1824a5d329f908b (adjusted scripts and updated dependencies)
  • Fixed a few issues in PinnerConnector and raceAgainstTimeout
  • Made the Store <-> PinnerConnector connection more resilient

Deletions ⚰️

  • I removed a test that just tested itself.

Notes 📒

Please wipe your node_modules folder and update the submodules after this is merged:

rm -rf node_modules
yarn --pure-lockfile
git submodule update --recursive

To the reviewers: Please test that it works for you!

Resolves #1077

Copy link
Contributor

@JamesLefrere JamesLefrere left a comment

Choose a reason for hiding this comment

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

This looks good! The only thing I think is worth a look is the debug env var for pinner; it'd be better if that were configurable.

@@ -17,7 +17,10 @@ export const raceAgainstTimeout = async (
timeout = setTimeout(() => reject(throwError), ms);
});
try {
return Promise.race([timeoutPromise, promise]);
// To be able to use the async error handling here, we need to explicitly
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, new to me, great find (and thanks for the comment).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah idk, might have to do with Babel transpilation? We might want to test this

Copy link
Contributor

Choose a reason for hiding this comment

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

Had a quick google, I was suspecting it could have been, but haven't found anything exactly like this.

stdio: 'pipe',
env: {
...process.env,
DEBUG: 'pinner:*',
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could get this from process.env under another name? Perhaps we won't want debugging on by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah you might be right. There's a lot of output there.

@@ -156,6 +168,17 @@ class PinnerConnector extends EventEmitter {
this._roomMonitor.on('error', log);
}

async ready() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good 👍

@@ -179,12 +202,15 @@ class PinnerConnector extends EventEmitter {
type: PIN_ACTIONS.LOAD_STORE,
payload: { address },
});
return raceAgainstTimeout(
const [heads] = await raceAgainstTimeout(
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, yeah, I don't know how it worked before either 🤷‍♂️

@chmanie
Copy link
Member Author

chmanie commented Apr 21, 2019

Did you try this locally @JamesLefrere?

@JamesLefrere
Copy link
Contributor

To the reviewers: Please test that it works for you!

Oops, I didn't see this. Will do 👍

@chmanie
Copy link
Member Author

chmanie commented Apr 22, 2019

I'm putting this back into in-progress as it seems we're far from done here.

@chmanie
Copy link
Member Author

chmanie commented Apr 23, 2019

On hold until @thiagodelgado111 merges the orbit-db upstream PR

@todo
Copy link

todo bot commented May 5, 2019

it might be worthwhile finding out why we need to debounce this in the first place

https://github.com/JoinColony/colonyDapp/blob/aa89dc396e1fbf0b29396c8d6d095ebf6fcd47a3/src/lib/database/stores/Store.js#L46-L51


This comment was generated by todo based on a @todo comment in aa89dc396e1fbf0b29396c8d6d095ebf6fcd47a3 in #1086. cc @JoinColony.

@todo
Copy link

todo bot commented May 5, 2019

Improve error modes for failed pinned store requests

This could be dangerous in case of an unfinished replication. We have to account for that Quick fix could be to just also wait for the full replication, which might be a performance hit


https://github.com/JoinColony/colonyDapp/blob/aa89dc396e1fbf0b29396c8d6d095ebf6fcd47a3/src/lib/database/stores/Store.js#L70-L75


This comment was generated by todo based on a @todo comment in aa89dc396e1fbf0b29396c8d6d095ebf6fcd47a3 in #1086. cc @JoinColony.

@chmanie chmanie force-pushed the bug/1077-pinion-connection branch 2 times, most recently from fae39c8 to e325a60 Compare May 20, 2019 18:01
@todo
Copy link

todo bot commented May 24, 2019

Improve replication check

This is not super accurate as the pinner could have the same number of heads but different ones. This can be improved but checking other internal states (like orbit stores do?). For now it's probably ok. Also, maybe it doesn't really need to be super accurate, as we're replicating anyways.


https://github.com/JoinColony/colonyDapp/blob/0b278dacfec0083273c43b9e4a77e3faf40d9d1b/src/lib/database/stores/Store.js#L111-L116


This comment was generated by todo based on a @todo comment in 0b278dacfec0083273c43b9e4a77e3faf40d9d1b in #1086. cc @JoinColony.

@thiagodelgado111
Copy link
Contributor

One thing that I noticed though:

14:32:08 › /Users/thiagodelgado/code/colonyDapp/node_modules/tree-kill/index.js:83
    ps.stdout.on('data', function (data) {
              ^
TypeError: Cannot read property 'on' of undefined
    at buildProcessTree (/Users/thiagodelgado/code/colonyDapp/node_modules/tree-kill/index.js:83:15)
    at /Users/thiagodelgado/code/colonyDapp/node_modules/tree-kill/index.js:104:11
    at Array.forEach (<anonymous>)
    at ChildProcess.onClose (/Users/thiagodelgado/code/colonyDapp/node_modules/tree-kill/index.js:99:31)
    at ChildProcess.emit (events.js:189:13)
    at maybeClose (internal/child_process.js:970:16)
    at Socket.stream.socket.on (internal/child_process.js:389:11)
    at Socket.emit (events.js:189:13)
    at Pipe._handle.close (net.js:597:12)

This seems to be a problem with node-tree-kill (pkrumins/node-tree-kill#17) and shouldn't block us from merging the PR. Just putting it out there. In fact, I think I've mentioned it in the past and someone told me it was a known issue

@chmanie
Copy link
Member Author

chmanie commented Jun 10, 2019

Hmm, @thiagodelgado111 I think that's our fault. Let me see.

@chmanie chmanie force-pushed the bug/1077-pinion-connection branch from 1107a91 to 5d51c7b Compare June 10, 2019 16:21
@chmanie chmanie merged commit 1fc84c3 into master Jun 10, 2019
@todo todo bot mentioned this pull request Jun 10, 2019
@chmanie chmanie deleted the bug/1077-pinion-connection branch June 10, 2019 16: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.

Repair connection to pinion
3 participants