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

pageserver: tweak period of imitate_layer_accesses #4859

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

jcsp
Copy link
Collaborator

@jcsp jcsp commented Aug 1, 2023

Problem

When the eviction threshold is an integer multiple of the eviction period, it is unreliable to skip imitating accesses based on whether the last imitation was more recent than the threshold.

This is because as finite time passes
between the time used for the periodic execution, and the 'now' time used for updating last_layer_access_imitation. When this is just a few milliseconds, and everything else is on-time, then a 5 second threshold with a 1 second period will end up entering its 5th iteration slightly less than 5 second since last_layer_access_imitation, and thereby skipping instead of running the imitation. If a few milliseconds then pass before we check the access time of a file that should have been bumped by the imitation pass, then we end up evicting something we shouldn't have evicted.

Summary of changes

We can make this race far less likely by using the threshold minus one interval as the period for re-executing the imitate_layer_accesses: that way we're not vulnerable to racing by just a few millis, and there would have to be a delay of the order period to cause us to wrongly evict a layer.

This is not a complete solution: it would be good to revisit this and use a non-walltime mechanism for pinning these layers into local storage, rather than relying on bumping access times.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

When the eviction threshold is an integer multiple of the
eviction period, it is unreliable to skip imitating accesses
based on whether the last imitation was more recent than
the threshold.

This is because as finite time passes
between the time used for the periodic execution, and
the 'now' time used for updating last_layer_access_imitation.
When this is just a few milliseconds, and everything else
is on-time, then a 5 second threshold with a 1 second period
will end up entering its 5th iteration slightly _less than_
5 second since last_layer_access_imitation, and thereby
skipping instead of running the imitation.  If a few milliseconds
then pass before we check the access time of a file that
_should_ have been bumped by the imitation pass, then
we end up evicting something we shouldn't have evicted.

This is not a complete solution: it would be good to revisit this
and use a non-walltime mechanism for pinning these layers into
local storage, rather than relying on bumping access times.
@jcsp jcsp added t/bug Issue Type: Bug c/storage/pageserver Component: storage: pageserver labels Aug 1, 2023
@jcsp
Copy link
Collaborator Author

jcsp commented Aug 1, 2023

There is a ticket for this test's instability here: #4154 although the analysis on that ticket suggests that the underlying issue was blocking I/Os which this period-tweaking might not help with if a system was heavily loaded enough.

This might also help with #4040, as it looks like the symptom of that was unexpected evictions of things that should have been touched by imitate_layer_accesses.

@github-actions
Copy link

github-actions bot commented Aug 1, 2023

1240 tests run: 1189 passed, 0 failed, 51 skipped (full report)


Flaky tests (1)

Postgres 14

  • test_get_tenant_size_with_multiple_branches: debug

Copy link
Member

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

Inclined to try this regardless of me really seeing how helpful it could be; the only risk is slightly more imitation and I doubt we can measure the increase as it is right now.

@jcsp jcsp marked this pull request as ready for review August 1, 2023 11:23
@jcsp jcsp requested review from a team as code owners August 1, 2023 11:23
@jcsp jcsp requested review from awestover and problame and removed request for a team August 1, 2023 11:23
@jcsp jcsp merged commit 7c076ed into main Aug 1, 2023
@jcsp jcsp deleted the jcsp/test-threshold-based-eviction-flake branch August 1, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/storage/pageserver Component: storage: pageserver t/bug Issue Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants