influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

fix(tsi): retaining fileset should not copy pointer

Open foobar opened this issue 5 years ago • 3 comments

Current implementation of retainFileSet is not safe because it returns p.fileSet directly. It is supposed to be protected by mutex:

func (p *Partition) retainFileSet() *FileSet {
	fs := p.fileSet
	fs.Retain()
	return fs
}

The bug may lead to deadlock if the fileset is modified while there is compaction.

foobar avatar Jul 15 '20 07:07 foobar

The CI will success when https://github.com/influxdata/influxdb/pull/18961 is merged

foobar avatar Jul 15 '20 12:07 foobar

@dgnorton I suppose this fix needs to be ported back to 1.7/1.8

foobar avatar Jul 16 '20 13:07 foobar

@foobar - can you make a unit test for this showing the problem?

davidby-influx avatar Jun 23 '22 17:06 davidby-influx

rereview the code, FileSet.files is actually immutable so the clone is not needed.

foobar avatar Aug 15 '22 03:08 foobar