Browse Source
Merge pull request #1735 from qieqieplus/rocksdb
ignore decode error for non-entry data
pull/1743/head
Chris Lu
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
8 additions and
9 deletions
-
weed/filer/rocksdb/rocksdb_ttl.go
|
|
@ -23,17 +23,16 @@ func NewTTLFilter() gorocksdb.CompactionFilter { |
|
|
|
func (t *TTLFilter) Filter(level int, key, val []byte) (remove bool, newVal []byte) { |
|
|
|
// decode could be slow, causing write stall
|
|
|
|
// level >0 sst can run compaction in parallel
|
|
|
|
if t.skipLevel0 && level == 0 { |
|
|
|
return false, val |
|
|
|
} |
|
|
|
entry := filer.Entry{} |
|
|
|
if err := entry.DecodeAttributesAndChunks(val); err == nil { |
|
|
|
if entry.TtlSec == 0 || |
|
|
|
entry.Crtime.Add(time.Duration(entry.TtlSec)*time.Second).After(time.Now()) { |
|
|
|
return false, val |
|
|
|
if !t.skipLevel0 || level > 0 { |
|
|
|
entry := filer.Entry{} |
|
|
|
if err := entry.DecodeAttributesAndChunks(val); err == nil { |
|
|
|
if entry.TtlSec > 0 && |
|
|
|
entry.Crtime.Add(time.Duration(entry.TtlSec)*time.Second).Before(time.Now()) { |
|
|
|
return true, nil |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true, nil |
|
|
|
return false, val |
|
|
|
} |
|
|
|
|
|
|
|
func (t *TTLFilter) Name() string { |
|
|
|