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

feat(pageserver): do not read past image layers for vectored get #7773

Merged
merged 10 commits into from
May 20, 2024

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented May 15, 2024

Problem

Part of #7462

On metadata keyspace, vectored get will not stop if a key is not found, and will read past the image layer. However, the semantics is different from single get, because if a key does not exist in the image layer, it means that the key does not exist in the past, or have been deleted. This pull request fixed it by recording image layer coverage during the vectored get process and stop when the full keyspace is covered by an image layer. A corresponding test case is added to ensure generating image layer reduces the number of delta layers.

This optimization (or bug fix) also applies to rel block keyspaces. If a key is missing, we can know it's missing once the first image layer is reached. Page server will not attempt to read lower layers, which potentially incurs layer downloads + evictions.

Summary of changes

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

@skyzh skyzh requested a review from VladLazar May 15, 2024 20:15
@skyzh skyzh requested a review from a team as a code owner May 15, 2024 20:15
@skyzh skyzh mentioned this pull request May 15, 2024
24 tasks
Copy link

github-actions bot commented May 15, 2024

3078 tests run: 2951 passed, 0 failed, 127 skipped (full report)


Flaky tests (1)

Postgres 16

  • test_secondary_background_downloads: debug

Code coverage* (full report)

  • functions: 31.4% (6412 of 20427 functions)
  • lines: 48.1% (49276 of 102532 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
d72c0da at 2024-05-20T17:45:43.192Z :recycle:

Copy link
Contributor

@VladLazar VladLazar left a comment

Choose a reason for hiding this comment

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

Also, this change to vectored get definitely needs a test which validates we return a missing key error.

@skyzh skyzh force-pushed the skyzh/vector-get-image branch 3 times, most recently from fc1ecfd to b901f6a Compare May 16, 2024 20:37
@skyzh
Copy link
Member Author

skyzh commented May 16, 2024

added two test cases for missing key behavior on metadata + data keys. I have to admit it is too hard to generate custom image layers now. Tried several combinations of operation sequences and finally worked around duplicated layer panics.

@skyzh skyzh requested a review from VladLazar May 16, 2024 20:38
@skyzh
Copy link
Member Author

skyzh commented May 17, 2024

resolved the comments from the discussion. KeySpaceRandomAccum for image layer coverage, and removed the 'outer thing.

libs/pageserver_api/src/keyspace.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant.rs Outdated Show resolved Hide resolved
@skyzh skyzh requested a review from VladLazar May 17, 2024 18:18
@skyzh
Copy link
Member Author

skyzh commented May 17, 2024

ready for review :)

Copy link
Contributor

@VladLazar VladLazar left a comment

Choose a reason for hiding this comment

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

Approving with a few comments. I would let this soak in staging next week personally.

pageserver/src/tenant.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline.rs Outdated Show resolved Hide resolved
Base automatically changed from skyzh/sparse-image to main May 20, 2024 16:08
skyzh added 9 commits May 20, 2024 12:54
Signed-off-by: Alex Chi Z <chi@neon.tech>

fix clippy

Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh force-pushed the skyzh/vector-get-image branch from 849c05b to 6993a4f Compare May 20, 2024 16:56
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh force-pushed the skyzh/vector-get-image branch from 53acad7 to d72c0da Compare May 20, 2024 16:59
@skyzh skyzh merged commit 6810d2a into main May 20, 2024
55 checks passed
@skyzh skyzh deleted the skyzh/vector-get-image branch May 20, 2024 18:24
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