Skip to content

Commit

Permalink
meta: trigger compaction more aggresively when there are too many sli…
Browse files Browse the repository at this point in the history
…ces (#4309)
  • Loading branch information
SandyXSD committed Feb 3, 2024
1 parent ac29345 commit a9c631a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ func (m *redisMeta) Write(ctx Context, inode Ino, indx uint32, off uint32, slice
return nil
})
if err == nil {
needCompact = rpush.Val()%100 == 99
needCompact = rpush.Val()%100 == 99 || rpush.Val() > 350
}
return err
}, m.inodeKey(inode))
Expand Down
3 changes: 2 additions & 1 deletion pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,8 @@ func (m *dbMeta) Write(ctx Context, inode Ino, indx uint32, off uint32, slice Sl
}
_, err = s.Cols("length", "mtime", "ctime").Update(&n, &node{Inode: inode})
if err == nil {
needCompact = (len(ck.Slices)/sliceBytes)%100 == 99
ns := len(ck.Slices) / sliceBytes // number of slices
needCompact = ns%100 == 99 || ns > 350
}
return err
}, inode)
Expand Down
3 changes: 2 additions & 1 deletion pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -1716,7 +1716,8 @@ func (m *kvMeta) Write(ctx Context, inode Ino, indx uint32, off uint32, slice Sl
attr.Ctimensec = uint32(now.Nanosecond())
val := tx.append(m.chunkKey(inode, indx), marshalSlice(off, slice.Id, slice.Size, slice.Off, slice.Len))
tx.set(m.inodeKey(inode), m.marshal(&attr))
needCompact = (len(val)/sliceBytes)%100 == 99
ns := len(val) / sliceBytes // number of slices
needCompact = ns%100 == 99 || ns > 350
return nil
}, inode)
if err == nil {
Expand Down

0 comments on commit a9c631a

Please sign in to comment.