Skip to content

feat: WIP defer'ing compaction decrement #26273

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

Draft
wants to merge 2 commits into
base: master-1.x
Choose a base branch
from

Conversation

devanbenz
Copy link

No description provided.

p.levelCompacting[0] = false
p.mu.Unlock()
p.Compact()
defer func() {
Copy link
Member

Choose a reason for hiding this comment

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

The defer should go at the top of the lambda, otherwise this change won't actually make any difference. Even then, it would only make a difference if p.compactLogFile panics.

Copy link
Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

defer has to be called earlier to ensure execution on error.

p.levelCompacting[0] = false
p.mu.Unlock()
p.Compact()
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The defer has to be called before the p.compactLogFile


// Check for new compactions
p.Compact()
defer func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

the defer has to be called before the p.compactToLevel

@davidby-influx
Copy link
Contributor

Overall, I'm not sure the defer protects much. It will on a panic, but wouldn't that crash the instance, anyway (and that would reset any erroneous compaction count)?

What's the scenario where influxd doesn't crash but the decrement doesn't happen?

p.currentCompactionN--
p.levelCompacting[0] = false
p.mu.Unlock()
p.Compact()
Copy link
Member

Choose a reason for hiding this comment

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

The p.Compact call here leads to indirect tail-call recursion. Putting the call in a defer will add another level to the stack. Depending on how deep the recursion goes, adding this extra stack frame every time may cause problems. Do we think p.compactLogFile panics?

Copy link
Member

Choose a reason for hiding this comment

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

More specifically, do we think p.compactLogFile panics, and then that is recovered higher up in the stack? Otherwise, I don't see this change making any difference.

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.

3 participants