ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.03k stars 3k forks source link

IPNS mount does not work after daemon restart and mouting #2142

Open Kubuxu opened 8 years ago

Kubuxu commented 8 years ago
2d [@vs1:~/sites/kubuxu.ovh] 130 $ systemctl --user restart ipfs
2d [@vs1:~/sites/kubuxu.ovh] $ ipfs mount
IPFS mounted at: /ipfs
IPNS mounted at: /ipns
2d [@vs1:~/sites/kubuxu.ovh] $ ipfs name resolve
/ipfs/QmRSEt9LqrpBjgf39huPVe1aipGFNH8Qk9u7sUSyQSqt4T
2d [@vs1:~/sites/kubuxu.ovh] $ ls /ipns/local/
ls: reading directory /ipns/local: Input/output error
2d [@vs1:~/sites/kubuxu.ovh] 2 $ ipfs ls /ipfs/QmRSEt9LqrpBjgf39huPVe1aipGFNH8Qk9u7sUSyQSqt4T
QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH 6     404.html
QmNXXmV7XowpDuhsrF96N2ADegyPvwwyMJnW3RMwxqwzHb 4926  about/
QmRCnGA4bYTG1ybN2U7vuaWr3s3vUDtCuE5tpBKqAPd3mz 33804 css/
QmReZDKghnFerokm9vzxFFJ7jSKsz7us5tWD7hzLLzot1b 68778 fonts/
QmVvRjTKyx3UySR1CyjEcnBDEPYcLBoqEFVyT3NAXyFko2 5129  index.html
QmeLs8b61eMw9FceAXT4V6NJJ1gPJuchC7scNxKqjzGjgW 5136  index.xml
QmdcJzyjMYRWXJU1JzdFUvm6huJGMG7PSB4XaGbnAn7hfL 94177 js/
Qmd1LxtACZvQLwTGH9d5muu7Xva7HmS77xhuKo498LysHS 452   page/
QmctpNqLdJZk4YF8FT3urdCyNxoPcvV9qJUUeQ16DidaW4 28338 post/
QmZHgp9zNPGMzVPq8mQE6U7PJ8jjN7SsWuizxpPNaEMtcR 700   sitemap.xml
QmVCnSBtWci1BTUvWigNnTVfbPK1qvRm1SpM1EePYLhuKK 14385 tags/

systemd restarts the daemon by shutting it down and starting again. Shutdown unmounts FUSE

2d [@vs1:~/sites/kubuxu.ovh] 2 $ ls /ipns/
local  QmdKbeXoXnMbPDfLsAFPGZDJ41bQuRNKALQSydJ66k1FfH
2d [@vs1:~/sites/kubuxu.ovh] $ systemctl --user stop ipfs
2d [@vs1:~/sites/kubuxu.ovh] $ ls /ipns/
2d [@vs1:~/sites/kubuxu.ovh] $

Failing syscall is getdents:

stat("/ipns/QmdKbeXoXnMbPDfLsAFPGZDJ41bQuRNKALQSydJ66k1FfH/", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
stat("/ipns/QmdKbeXoXnMbPDfLsAFPGZDJ41bQuRNKALQSydJ66k1FfH/", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/ipns/QmdKbeXoXnMbPDfLsAFPGZDJ41bQuRNKALQSydJ66k1FfH/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
getdents(3, 0xc49cd0, 32768)            = -1 EIO (Input/output error)
Kubuxu commented 8 years ago

It wasn't the issue

I've found the issue:

-r--r--r-- 1 kubuxu kubuxu    0 Jan  1 13:33 404.html
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 about
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 css
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 fonts
-r--r--r-- 1 kubuxu kubuxu    0 Jan  1 13:33 index.html
-r--r--r-- 1 kubuxu kubuxu 5072 Jan  1 13:33 index.xml
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 js
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 page
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 post
-r--r--r-- 1 kubuxu kubuxu  636 Jan  1 13:33 sitemap.xml
dr-xr-xr-x 1 kubuxu kubuxu    0 Jan  1 13:33 tags

The directory is getting corrupted for some reason. It might be connected with fact that my leveldb was corrupted some time ago.

Kubuxu commented 8 years ago

Still doesn't work. This time it fails on getting about, it's content is fine.

Can someone try recreating it?

  1. Publish directory (possibly /ipfs/QmS66gxnpRxHDF1YnChjjpBm2KhCbh3TSfJKRyo2PovjTy/, which is my site hosted 24/7) to ipns.
  2. ipfs mount
  3. ls /ipns/local/

Expected: list of files Result: ls: reading directory /ipns/local/: Input/output error

It was able to track it down to this line: https://github.com/ipfs/go-ipfs/blob/master/fuse/ipns/ipns_unix.go#L275

Fails with error: file does not exist, and file is about (which is directory), and previously it was index.html empty at the time.

The site works as you can see on: https://ipfs.io/ipfs/QmS66gxnpRxHDF1YnChjjpBm2KhCbh3TSfJKRyo2PovjTy/

whyrusleeping commented 8 years ago

my guess is that the mountpoint doesnt get fully unmounted before the daemon process is killed, resulting in fuse being in a weird state. We are working on getting fuse tests working on CI so we can test these things better

Kubuxu commented 8 years ago

It is probably that as published hash changed after restart.