holepunchto / hyperdrive

Hyperdrive is a secure, real time distributed file system
Apache License 2.0
1.86k stars 134 forks source link

Unable to read replicated hyperdrives with mounts #258

Closed mjp0 closed 1 year ago

mjp0 commented 4 years ago

I ran into a bug with hypercore-8 branch where hyperdrive hangs if you try to read a mount from replicated hyperdrive. I'm not sure whether this is a bug with hyperdrive or mountable-hypertrie.

I created a test case and it's available at https://github.com/mafintosh/hyperdrive/pull/257

andrewosh commented 4 years ago

Appreciate the test @markopolojarvi. I'll check it out and report back here when I figure out the root cause.

andrewosh commented 4 years ago

K so looks like the issue here's that when you create drive3, you're passing in a null value for drive1.key because drive1 isn't ready yet.

To fix the test, you can just defer the creation of drive3 until right after the drive1.ready line, or just use drive1.key in the second_drive function (since it doesn't look like you're calling any methods on drive3 directly) :)

Getting the initialization order right is definitely tricky, but most operation's (including the getters) won't work correctly until after ready's been called as a general rule of thumb.

Don't think there are any deeper replication issues here -- at least not surfaced by #257. Very much appreciate including a good test with the issue though!

andrewosh commented 4 years ago

Actually I'll leave this open in case the create issue was just a small mistake and not related to the core issue.

@markopolojarvi is the test case you made a modified version of some other failing case you're seeing elsewhere.

mjp0 commented 4 years ago

@andrewosh What a brainfart with the drive 1 key... sorry about that.

All this is related to the problem with the same nested replication structure over hyperswarm, test case at https://pastebin.com/UmVmFRdf. Unless I'm having another brainfart, in that test case initialization is done right but for some reason it still dies.

The reason I did the tape test was that @mafintosh asked if I could replicate the problem with plain old replicate() and it seems I could, if I did the initialization wrong ;)