aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-08-15 23:07:58 -0700
committerChris Lu <chris.lu@gmail.com>2021-08-15 23:07:58 -0700
commit40dc283b2dfc027018a04938f22bffcc1afd7b45 (patch)
tree69e8d46d0c42f9e23e0371fab89ca0861ebfd9bc
parent72eb6d5b9da9196a17f7ec854d2c4d44a84fad73 (diff)
downloadseaweedfs-40dc283b2dfc027018a04938f22bffcc1afd7b45.tar.xz
seaweedfs-40dc283b2dfc027018a04938f22bffcc1afd7b45.zip
fix locating data chunks
-rw-r--r--weed/Makefile2
-rw-r--r--weed/filer/stream.go19
2 files changed, 18 insertions, 3 deletions
diff --git a/weed/Makefile b/weed/Makefile
index 205104969..46034977e 100644
--- a/weed/Makefile
+++ b/weed/Makefile
@@ -40,7 +40,7 @@ debug_filer_copy:
debug_filer_remote_sync:
go build -gcflags="all=-N -l"
- dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- -v=4 filer.remote.sync -filer="localhost:8888" -dir=/buckets/b2 -timeAgo=10000h
+ dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec weed -- -v=4 filer.remote.sync -filer="localhost:8888" -dir=/buckets/b2 -timeAgo=1h
debug_master_follower:
go build -gcflags="all=-N -l"
diff --git a/weed/filer/stream.go b/weed/filer/stream.go
index 9f28056cd..05621a5c3 100644
--- a/weed/filer/stream.go
+++ b/weed/filer/stream.go
@@ -237,10 +237,25 @@ func (c *ChunkStreamReader) prepareBufferFor(offset int64) (err error) {
// need to seek to a different chunk
currentChunkIndex := sort.Search(len(c.chunkViews), func(i int) bool {
- return c.chunkViews[i].LogicOffset <= offset
+ return offset < c.chunkViews[i].LogicOffset
})
if currentChunkIndex == len(c.chunkViews) {
- return io.EOF
+ // not found
+ if c.chunkViews[0].LogicOffset <= offset {
+ currentChunkIndex = 0
+ } else if c.chunkViews[len(c.chunkViews)-1].LogicOffset <= offset {
+ currentChunkIndex = len(c.chunkViews) -1
+ } else {
+ return io.EOF
+ }
+ } else if currentChunkIndex > 0 {
+ if c.chunkViews[currentChunkIndex-1].LogicOffset <= offset {
+ currentChunkIndex -= 1
+ } else {
+ return fmt.Errorf("unexpected1 offset %d", offset)
+ }
+ } else {
+ return fmt.Errorf("unexpected2 offset %d", offset)
}
// positioning within the new chunk