Skip to content

Commit

Permalink
fix: reset slices in meta.Read when chunk not exists (juicedata#4366)
Browse files Browse the repository at this point in the history
Signed-off-by: jiefeng <[email protected]>
  • Loading branch information
jiefenghuang authored Jan 19, 2024
1 parent 5d2274d commit a43dea7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,10 @@ func (m *redisMeta) Read(ctx Context, inode Ino, indx uint32, slices *[]Slice) (
m.touchAtime(ctx, inode, nil)
}
}()

if slices != nil {
*slices = nil
}
f := m.of.find(inode)
if f != nil {
f.RLock()
Expand Down
11 changes: 8 additions & 3 deletions pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ import (
"syscall"
"time"

"github.com/juicedata/juicefs/pkg/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"xorm.io/xorm"
"xorm.io/xorm/log"
"xorm.io/xorm/names"

"github.com/juicedata/juicefs/pkg/utils"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

const MaxFieldsCountOfTable = 16 // node table
Expand Down Expand Up @@ -2194,6 +2195,10 @@ func (m *dbMeta) Read(ctx Context, inode Ino, indx uint32, slices *[]Slice) (rer
m.touchAtime(ctx, inode, nil)
}
}()

if slices != nil {
*slices = nil
}
f := m.of.find(inode)
if f != nil {
f.RLock()
Expand Down
4 changes: 4 additions & 0 deletions pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,10 @@ func (m *kvMeta) Read(ctx Context, inode Ino, indx uint32, slices *[]Slice) (rer
m.touchAtime(ctx, inode, nil)
}
}()

if slices != nil {
*slices = nil
}
f := m.of.find(inode)
if f != nil {
f.RLock()
Expand Down

0 comments on commit a43dea7

Please sign in to comment.