Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Vacuum compressed chunks missing stats #1804

Merged
merged 1 commit into from Dec 22, 2022
Merged

Conversation

jgpruitt
Copy link
Contributor

@jgpruitt jgpruitt commented Dec 19, 2022

Description

We have seen instances in which compresses chunks are missing statistics. Autovacuum ignores tables that are missing statistics. Analyzing these tables does not help since we rarely modify chunks after they are compressed. Therefore, these chunks are ignored until they pass the vacuum_freeze_max_age. This can be bad for performance. So, the vacuum engine makes a second pass looking for these chunks and vacuums them. We only use one worker for these.

See also: timescale/promscale_extension#595

Merge requirements

Please take into account the following non-code changes that you may need to make with your PR:

  • CHANGELOG entry for user-facing changes
  • Updated the relevant documentation

@jgpruitt jgpruitt self-assigned this Dec 19, 2022
@jgpruitt jgpruitt force-pushed the john/chunks_to_vacuum branch 2 times, most recently from 1cb22b4 to c05ec6e Compare December 19, 2022 18:32
@jgpruitt jgpruitt marked this pull request as ready for review December 19, 2022 18:48
@jgpruitt jgpruitt requested a review from a team as a code owner December 19, 2022 18:48
@jgpruitt jgpruitt requested a review from cevian December 19, 2022 18:49
docs/vacuum.md Outdated Show resolved Hide resolved
pkg/vacuum/vacuum.go Outdated Show resolved Hide resolved
// next, we look for compressed chunks that have never been vacuum and seem to be missing
// statistics. autovacuum will ignore these until they hit vacuum_freeze_min_age, so let's
// catch these early
for {
Copy link
Contributor

Choose a reason for hiding this comment

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

This for, I believe can starve out the loop above and vice-versa,.This should probably be one for loop that alternates between the two queries. Or maybe the loop above is more important and should starve-out this loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed. I think the first loop is more important. I will limit the second for loop to 3 loops. If it finishes its work, the run ends. If it doesn't finish in 3 iterations, it will give the first loop another turn before continuing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

take another look? @cevian

@jgpruitt jgpruitt force-pushed the john/chunks_to_vacuum branch 4 times, most recently from 9d6e6fe to 5201ed5 Compare December 20, 2022 16:41
@jgpruitt jgpruitt requested a review from cevian December 20, 2022 16:55
pkg/vacuum/vacuum.go Outdated Show resolved Hide resolved
pkg/vacuum/vacuum.go Outdated Show resolved Hide resolved
@jgpruitt jgpruitt force-pushed the john/chunks_to_vacuum branch 2 times, most recently from 94a0812 to 2dcc607 Compare December 21, 2022 15:06
Copy link
Contributor

@sumerman sumerman left a comment

Choose a reason for hiding this comment

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

🔥 ❤️ 🔥

@jgpruitt jgpruitt force-pushed the john/chunks_to_vacuum branch 2 times, most recently from d13dfa5 to d8ed2ca Compare December 21, 2022 16:40

// if this workload already finished, don't continue working it, work the other
if w.finished {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this mean chunksMissingStats can indefinitely starve out chunksToFreeze after chunksToFreeze.finish becomes true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. dangit.

We have seen instances in which compresses chunks are missing
statistics. Autovacuum ignores tables that are missing statistics.
Analyzing these tables does not help since we rarely modify chunks
after they are compressed. Therefore, these chunks are ignored until
they pass the vacuum_freeze_max_age. This can be bad for performance.
So, the vacuum engine looks for these chunks and vacuums them. We
only use one worker for these.
Copy link
Contributor

@cevian cevian left a comment

Choose a reason for hiding this comment

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

I think the metrics could be improved but wont hold up the PR for that

return
log.Error("msg", fmt.Sprintf("failed to list %s", w.name), "error", err)
w.stop = true
continue
}
tablesNeedingVacuum.Set(float64(len(chunks)))
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we add separate metrics as well to count the work for each type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. I'll do a follow-up PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jgpruitt jgpruitt merged commit 93ed639 into master Dec 22, 2022
@jgpruitt jgpruitt deleted the john/chunks_to_vacuum branch December 22, 2022 02:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants