From ce1efeb0eb91b1c2ea87e17eeed230b9b20aeb1f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 9 Oct 2021 04:54:14 -0700 Subject: [PATCH] adds more error message --- weed/storage/volume_backup.go | 3 +- weed/storage/volume_write_test.go | 69 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 weed/storage/volume_write_test.go diff --git a/weed/storage/volume_backup.go b/weed/storage/volume_backup.go index 7fadd6fef..500f48b23 100644 --- a/weed/storage/volume_backup.go +++ b/weed/storage/volume_backup.go @@ -191,12 +191,13 @@ func (v *Volume) BinarySearchByAppendAtNs(sinceNs uint64) (offset Offset, isLast // read the appendAtNs for entry m offset, err = v.readOffsetFromIndex(m) if err != nil { + err = fmt.Errorf("read entry %d: %v", m, err) return } mNs, nsReadErr := v.readAppendAtNs(offset) if nsReadErr != nil { - err = nsReadErr + err = fmt.Errorf("read entry %d offset %d: %v", m, offset, nsReadErr) return } diff --git a/weed/storage/volume_write_test.go b/weed/storage/volume_write_test.go new file mode 100644 index 000000000..e0ee3dac7 --- /dev/null +++ b/weed/storage/volume_write_test.go @@ -0,0 +1,69 @@ +package storage + +import ( + "fmt" + "github.com/chrislusf/seaweedfs/weed/storage/needle" + "github.com/chrislusf/seaweedfs/weed/storage/super_block" + "io/ioutil" + "os" + "testing" + "time" +) + +func TestSearchVolumesWithDeletedNeedles(t *testing.T) { + dir, err := ioutil.TempDir("", "example") + if err != nil { + t.Fatalf("temp dir creation: %v", err) + } + defer os.RemoveAll(dir) // clean up + + v, err := NewVolume(dir, dir, "", 1, NeedleMapInMemory, &super_block.ReplicaPlacement{}, &needle.TTL{}, 0, 0) + if err != nil { + t.Fatalf("volume creation: %v", err) + } + + count := 10 + + for i:=1;i