Skip to content

Commit

Permalink
Merge pull request #7196 from benbjohnson/mmap-fix
Browse files Browse the repository at this point in the history
Fix mmap dereferencing
  • Loading branch information
benbjohnson authored Aug 24, 2016
2 parents 8bb3fcb + cc628a1 commit a30f9b6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- [#1834](https://github.com/influxdata/influxdb/issues/1834): Drop time when used as a tag or field key.
- [#7152](https://github.com/influxdata/influxdb/issues/7152): Decrement number of measurements only once when deleting the last series from a measurement.
- [#7177](https://github.com/influxdata/influxdb/issues/7177): Fix base64 encoding issue with /debug/vars stats.
- [#7196](https://github.com/influxdata/influxdb/ssues/7196): Fix mmap dereferencing, fixes #7183, #7180

## v1.0.0 [unreleased]

Expand Down
7 changes: 5 additions & 2 deletions tsdb/engine/tsm1/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,11 @@ func (f *FileStore) Close() error {
f.mu.Lock()
defer f.mu.Unlock()

for _, f := range f.files {
f.Close()
for _, file := range f.files {
if f.dereferencer != nil {
file.deref(f.dereferencer)
}
file.Close()
}

f.files = nil
Expand Down
2 changes: 1 addition & 1 deletion tsdb/engine/tsm1/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func (t *TSMReader) BlockIterator() *BlockIterator {

// deref removes mmap references held by another object.
func (t *TSMReader) deref(d dereferencer) {
if acc, ok := t.accessor.(*mmapAccessor); ok {
if acc, ok := t.accessor.(*mmapAccessor); ok && acc.b != nil {
d.Dereference(acc.b)
}
}
Expand Down
6 changes: 3 additions & 3 deletions tsdb/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -1503,9 +1503,9 @@ func (s *Series) Dereference(b []byte) {
min := uintptr(unsafe.Pointer(&b[0]))
max := min + uintptr(len(b))

for _, t := range s.Tags {
deref(&t.Key, min, max)
deref(&t.Value, min, max)
for i := range s.Tags {
deref(&s.Tags[i].Key, min, max)
deref(&s.Tags[i].Value, min, max)
}

s.mu.Unlock()
Expand Down

0 comments on commit a30f9b6

Please sign in to comment.