Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition when opening and closing tsdb concurrently #3959

Merged

Conversation

alanprot
Copy link
Member

@alanprot alanprot commented Mar 17, 2021

What this PR does:
Fix race condition when opening and closing tsdb concurrently.

Before this change, we had a potential race condition where we released the userState lock before actually deleting the local directory, while ingester received a new request and is trying to create a new TSDB.

We could see on our log the following errors/warns:

level=error ts=2021-03-13T17:35:58.129738177Z caller=ingester_v2.go:1759 msg="failed to delete local TSDB" user=tenant_id err="unlinkat /data/tsdb/tenant_id/wal: directory not empty"
...
...
level=warn ts=2021-03-13T17:35:58.424349159Z caller=grpc_logging.go:38 method=/cortex.Ingester/Push duration=303.330741ms err="user=tenant_id: failed to open TSDB: /data/tsdb/tenant_id: repair corrupted WAL: cannot handle error: open WAL segment: 412: open /data/tsdb/tenant_id/wal/00000412: no such file or directory" msg="gRPC\n"

The PR includes a test that reproduce the problem.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • [NA] Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@alanprot alanprot force-pushed the fix/close-open-tsdb-concurrently branch from bf8a1d4 to 6ee1b65 Compare March 17, 2021 02:43
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pracucci pracucci merged commit 4de0d40 into cortexproject:master Mar 19, 2021
@alanprot
Copy link
Member Author

Thanks!! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants