Skip to content

Remove tenant when last block is removed from local backend#1947

Merged
joe-elliott merged 8 commits intografana:mainfrom
joe-elliott:drop-zero-length-wals
Dec 15, 2022
Merged

Remove tenant when last block is removed from local backend#1947
joe-elliott merged 8 commits intografana:mainfrom
joe-elliott:drop-zero-length-wals

Conversation

@joe-elliott
Copy link
Copy Markdown
Collaborator

@joe-elliott joe-elliott commented Dec 13, 2022

What this PR does:
This fixes a long running issue where tenants were persisted even if they had a zero length wal. The issue was that when rediscovering local blocks a tenant was still found even if there were no blocks. This PR fixes the issue with two changes:

  • When rediscovering local blocks don't include tenants without blocks
  • When clearing a block in the local backend remove the tenant as well

Technically only the first of the two is needed and would be a safer change. Having the second is nice because it will clear up folders in our ingester local backends. Should we remove the second change and err towards safety? Especially with the 2.0 release coming up?

Checklist

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

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott
Copy link
Copy Markdown
Collaborator Author

joe-elliott commented Dec 13, 2022

Another note:

Currently when rediscovering local blocks this PR will nicely skip tenants that don't have blocks. However, it will leave those folders forever. Only when a block is cleared from the local backend do we make the check on whether or not to remove the tenant. This PR, as is, will not clean up already existing empty tenant folders in the local backend.

Comment thread tempodb/backend/local/compactor.go Outdated
@mdisibio
Copy link
Copy Markdown
Contributor

Only when a block is cleared from the local backend do we make the check on whether or not to remove the tenant. This PR, as is, will not clean up already existing empty tenant folders in the local backend.

Does it make sense to do local folder cleanup at ingester shutdown, which could also handle this scenario?

@joe-elliott
Copy link
Copy Markdown
Collaborator Author

joe-elliott commented Dec 13, 2022

Does it make sense to do local folder cleanup at ingester shutdown, which could also handle this scenario?

This is likely the better approach. Let me see if I can put something together 👍

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott
Copy link
Copy Markdown
Collaborator Author

@mdisibio i took your suggestion and implemented clean up on shutdown. let me know what you think

Signed-off-by: Joe Elliott <number101010@gmail.com>
// Shutdown implements backend.Reader
// Shutdown implements backend.Reader. It attempts to clear all tenants
// that do not have blocks.
func (rw *Backend) Shutdown() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Forgot this existed. Excellent.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. It's weird that Shutdown() on the Reader interface does the job of cleaning up, but meh. We should combine these interfaces anyway. I don't think much is gained from the split up.

(or just add Shutdown to the writer?)

@joe-elliott joe-elliott merged commit 93a264c into grafana:main Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants