Skip to content

Commit

Permalink
Remove refs after closing index writer.
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Dec 23, 2020
1 parent 72e2297 commit 750e7de
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/dbnode/persist/fs/persist_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,6 @@ type dataPersistManager struct {
snapshotID uuid.UUID
}

// Support writing to multiple index blocks/filesets during index persist.
// This allows us to prepare an index fileset writer per block start.
type singleUseIndexWriter struct {
// back-ref to the index persist manager so we can share resources there
manager *indexPersistManager
writer IndexFileSetWriter

state singleUseIndexWriterState
}

type singleUseIndexWriterState struct {
// identifiers required to know which file to open
// after persistence is over
Expand All @@ -135,6 +125,16 @@ type singleUseIndexWriterState struct {
writeErr error
}

// Support writing to multiple index blocks/filesets during index persist.
// This allows us to prepare an index fileset writer per block start.
type singleUseIndexWriter struct {
// back-ref to the index persist manager so we can share resources there
manager *indexPersistManager
writer IndexFileSetWriter

state singleUseIndexWriterState
}

func (s *singleUseIndexWriter) persistIndex(builder segment.Builder) error {
// Lock the index persist manager as we're sharing the segment builder as a resource.
s.manager.Lock()
Expand Down Expand Up @@ -167,6 +167,8 @@ func (s *singleUseIndexWriter) closeIndex() ([]segment.Segment, error) {
// This writer will be thrown away after we're done persisting.
defer func() {
s.state = singleUseIndexWriterState{fileSetType: -1}
s.manager = nil
s.writer = nil
}()

// s.e. we're done writing all segments for PreparedIndexPersist.
Expand Down

0 comments on commit 750e7de

Please sign in to comment.