Skip to content

Commit

Permalink
[dbnode] Release refs to tags after data fileset write close (#1693)
Browse files Browse the repository at this point in the history
  • Loading branch information
robskillington authored Jun 9, 2019
1 parent 32fb10d commit fb40fe6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/dbnode/persist/fs/read_write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ func writeTestDataWithVolume(
digest.Checksum(entries[i].data)))
}
assert.NoError(t, w.Close())

// Assert that any index entries released references they held
writer, ok := w.(*writer)
require.True(t, ok)

// Take ref to wholly allocated index entries slice
slice := writer.indexEntries[:cap(writer.indexEntries)]

// Check every entry has ID and Tags nil
for _, elem := range slice {
assert.Nil(t, elem.id)
assert.Nil(t, elem.tags.Values())
}
}

type readTestType uint
Expand Down
4 changes: 3 additions & 1 deletion src/dbnode/persist/fs/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ type indexEntry struct {
type indexEntries []indexEntry

func (e indexEntries) releaseRefs() {
// memset zero loop optimization
var zeroed indexEntry
for i := range e {
e[i].id = nil
e[i] = zeroed
}
}

Expand Down

0 comments on commit fb40fe6

Please sign in to comment.