aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-06-28 15:48:07 -0700
committerChris Lu <chris.lu@gmail.com>2021-06-28 15:48:07 -0700
commitfc8dd58aea0564087effa37fb2a0bc41066b6cdb (patch)
tree19122a1a54a9339bbe0f4d0ff6df7b32ae246624
parenta2979aa051692d5774d472e54ddaf974aabdb345 (diff)
downloadseaweedfs-fc8dd58aea0564087effa37fb2a0bc41066b6cdb.tar.xz
seaweedfs-fc8dd58aea0564087effa37fb2a0bc41066b6cdb.zip
volume: large_volume version has bug when using in memory index
fix https://github.com/chrislusf/seaweedfs/issues/2162
-rw-r--r--test/data/187.idxbin0 -> 1028959 bytes
-rw-r--r--weed/storage/needle_map/compact_map.go1
-rw-r--r--weed/storage/needle_map/compact_map_cases_test.go33
3 files changed, 34 insertions, 0 deletions
diff --git a/test/data/187.idx b/test/data/187.idx
new file mode 100644
index 000000000..d4cb42ef0
--- /dev/null
+++ b/test/data/187.idx
Binary files differ
diff --git a/weed/storage/needle_map/compact_map.go b/weed/storage/needle_map/compact_map.go
index 2b1a471bc..9495a49ab 100644
--- a/weed/storage/needle_map/compact_map.go
+++ b/weed/storage/needle_map/compact_map.go
@@ -96,6 +96,7 @@ func (cs *CompactSection) setOverflowEntry(skey SectionalNeedleId, offset Offset
cs.overflowExtra[i] = cs.overflowExtra[i-1]
}
cs.overflow[insertCandidate] = needleValue
+ cs.overflowExtra[insertCandidate] = needleValueExtra
}
}
diff --git a/weed/storage/needle_map/compact_map_cases_test.go b/weed/storage/needle_map/compact_map_cases_test.go
new file mode 100644
index 000000000..a0142b57d
--- /dev/null
+++ b/weed/storage/needle_map/compact_map_cases_test.go
@@ -0,0 +1,33 @@
+// +build 5BytesOffset
+
+package needle_map
+
+import (
+ "fmt"
+ "github.com/chrislusf/seaweedfs/weed/storage/types"
+ "github.com/stretchr/testify/assert"
+ "log"
+ "os"
+ "testing"
+)
+
+func Test5bytesIndexLoading(t *testing.T) {
+
+ indexFile, ie := os.OpenFile("../../../test/data/187.idx", os.O_RDWR|os.O_RDONLY, 0644)
+ if ie != nil {
+ log.Fatalln(ie)
+ }
+ defer indexFile.Close()
+ m, rowCount := loadNewNeedleMap(indexFile)
+
+ println("total entries:", rowCount)
+
+ key := types.NeedleId(0x671b905)
+
+ needle, found := m.Get(types.NeedleId(0x671b905))
+
+ fmt.Printf("%v key:%v offset:%v size:%v\n", found, key, needle.Offset, needle.Size)
+
+ assert.Equal(t, int64(12884911892)*8, needle.Offset.ToActualOffset(), "offset")
+
+}