Browse Source

set needle AppendAtNs value during writes

pull/702/head
Chris Lu 7 years ago
parent
commit
ea8ecf35f4
  1. 2
      weed/storage/volume_read_write.go
  2. 1
      weed/storage/volume_vacuum.go

2
weed/storage/volume_read_write.go

@ -101,6 +101,7 @@ func (v *Volume) writeNeedle(n *Needle) (size uint32, err error) {
} }
} }
n.AppendAtNs = uint64(time.Now().UnixNano())
if size, _, err = n.Append(v.dataFile, v.Version()); err != nil { if size, _, err = n.Append(v.dataFile, v.Version()); err != nil {
if e := v.dataFile.Truncate(offset); e != nil { if e := v.dataFile.Truncate(offset); e != nil {
err = fmt.Errorf("%s\ncannot truncate %s: %v", err, v.dataFile.Name(), e) err = fmt.Errorf("%s\ncannot truncate %s: %v", err, v.dataFile.Name(), e)
@ -139,6 +140,7 @@ func (v *Volume) deleteNeedle(n *Needle) (uint32, error) {
return size, err return size, err
} }
n.Data = nil n.Data = nil
n.AppendAtNs = uint64(time.Now().UnixNano())
_, _, err = n.Append(v.dataFile, v.Version()) _, _, err = n.Append(v.dataFile, v.Version())
return size, err return size, err
} }

1
weed/storage/volume_vacuum.go

@ -207,6 +207,7 @@ func (v *Volume) makeupDiff(newDatFileName, newIdxFileName, oldDatFileName, oldI
fakeDelNeedle := new(Needle) fakeDelNeedle := new(Needle)
fakeDelNeedle.Id = key fakeDelNeedle.Id = key
fakeDelNeedle.Cookie = 0x12345678 fakeDelNeedle.Cookie = 0x12345678
fakeDelNeedle.AppendAtNs = uint64(time.Now().UnixNano())
_, _, err = fakeDelNeedle.Append(dst, v.Version()) _, _, err = fakeDelNeedle.Append(dst, v.Version())
if err != nil { if err != nil {
return fmt.Errorf("append deleted %d failed: %v", key, err) return fmt.Errorf("append deleted %d failed: %v", key, err)

Loading…
Cancel
Save