coreos / torus

Torus Distributed Storage
https://coreos.com/blog/torus-distributed-storage-by-coreos.html
Apache License 2.0
1.77k stars 172 forks source link

When torus uses replication blockset, it causes panic during the blockset registration #370

Closed nak3 closed 7 years ago

nak3 commented 7 years ago

version

b6f7abae2d9992fd46937c1c6226799c49a5d6a7

issue

When torus uses replication blockset, it causes panic during the blockset registration (= access the mounted device by user).

reproduce step

1. initialize ring with replication blockset

$ ./bin/torusctl init --block-spec=rep --debug

2. run torus storage node

$ sudo ./bin/torusd --peer-address=http://192.168.121.119:4000 --debug  --data-dir=/tmp/foo1 --auto-join

3. Create and attach volume

./bin/torusctl volume create-block foo1 1GiB --debug
sudo ./bin/torusblk nbd foo1 /dev/nbd0 --debug

4. format the nbd device

sudo mkfs.ext4 /dev/nbd0

actual result

When formatting the device(step-4), torus client process causes panic as below.

[vagrant@torus1 torus]$  sudo ./bin/torusblk nbd foo1 /dev/nbd0 --debug
2016-10-29 12:04:12.758497 I | torus: creating metadata service: etcd
2016-10-29 12:04:12.761786 N | ring: Using ring that requests replication level 2, but has only 0 peers. Add nodes to match replication.
2016-10-29 12:04:12.762059 I | torus: creating blockstore: temp
2016-10-29 12:04:12.763085 N | ring: Using ring that requests replication level 2, but has only 0 peers. Add nodes to match replication.
2016-10-29 12:04:12.763327 D | gc: creating blockvol gc
2016-10-29 12:04:12.768099 D | blockset: using default replication (0) to unmarshal
panic: runtime error: makeslice: len out of range

goroutine 1 [running]:
panic(0xcc8800, 0xc820249310)
    /usr/lib/golang/src/runtime/panic.go:481 +0x3e6
github.com/coreos/torus/blockset.init.4.func1(0x0, 0x0, 0x0, 0x0, 0x7fc5d215a5d8, 0xc82029e600, 0x0, 0x0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/blockset/replication.go:28 +0xef
github.com/coreos/torus/blockset.createBlockset(0x2, 0x0, 0x0, 0x0, 0x0, 0x7fc5d215a5d8, 0xc82029e600, 0x0, 0x0, 0x0, ...)
    /home/vagrant/work/src/github.com/coreos/torus/blockset/blockset_main.go:77 +0xb1
github.com/coreos/torus/blockset.CreateBlocksetFromSpec(0xc820203a40, 0x2, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/blockset/blockset_main.go:110 +0x1ed
github.com/coreos/torus/block.(*BlockVolume).getOrCreateBlockINode(0xc82028c5e0, 0x3, 0x1, 0x0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/block/volume.go:82 +0x28d
github.com/coreos/torus/block.(*BlockVolume).OpenBlockFile(0xc82028c5e0, 0x0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/block/blockfile.go:32 +0x23b
main.nbdAction(0x12b49c0, 0xc82020d7a0, 0x2, 0x3)
    /home/vagrant/work/src/github.com/coreos/torus/cmd/torusblk/nbd.go:79 +0x4bc
github.com/coreos/torus/vendor/github.com/spf13/cobra.(*Command).execute(0x12b49c0, 0xc82020d710, 0x3, 0x3, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/vendor/github.com/spf13/cobra/command.go:565 +0x85a
github.com/coreos/torus/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x12b45c0, 0x12b49c0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/vendor/github.com/spf13/cobra/command.go:651 +0x55c
github.com/coreos/torus/vendor/github.com/spf13/cobra.(*Command).Execute(0x12b45c0, 0x0, 0x0)
    /home/vagrant/work/src/github.com/coreos/torus/vendor/github.com/spf13/cobra/command.go:610 +0x2d
main.main()
    /home/vagrant/work/src/github.com/coreos/torus/cmd/torusblk/main.go:108 +0x38