cockroachdb / cockroachdb/pebble

pebble: race between MemFS.Close and MemFS.Remove

Open
#1,236 6 comments 0 reactions 0 assignees View on GitHub
B-os-windows
Dominant language
Go
Stars
6k
Forks
584
Avg merge
16h 35m
Merged PRs (30d)
5

Description

The `tableCache` on master has a release loop which closes files, https://github.com/cockroachdb/pebble/blob/master/table_cache.go#L173. But it doesn't seem like we wait for a file to close before removing it.

- The `MemFS` keeps track of reference counts for the files which is decremented on `MemFS.Close`.
- `MemFS.Remove` errors out if we try to remove a file with a `ref count > 0`.
- So, I'm seeing a race where the `releaseLoop` function in the table cache only attempts to close a file, after `MemFS.Remove` has been called. This prevents the file from being deleted.
- Moreover, it seems as if we don't really do anything with the error returned from `d.opts.Cleaner.Clean` in `d.deleteObsoleteFile`. - The error gets logged here: https://github.com/cockroachdb/pebble/blob/master/compaction.go#L2872, but we don't do anything to rectify the error.

Jira issue: PEBBLE-220

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.