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): gc-compaction split over LSN #9900

Merged
merged 11 commits into from
Dec 12, 2024

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented Nov 26, 2024

Problem

part of #9114, stacked PR over #9897, partially refactored to help with #10031

Summary of changes

  • gc-compaction takes above_lsn parameter. We only compact the layers above this LSN, and all data below the LSN are treated as if they are on the ancestor branch.
  • refactored gc-compaction to take GcCompactJob that describes the rectangular range to be compacted.
  • Added unit test for this case.

@skyzh skyzh requested review from problame and arpad-m November 26, 2024 17:42
@skyzh skyzh requested a review from a team as a code owner November 26, 2024 17:42
@skyzh skyzh mentioned this pull request Nov 26, 2024
28 tasks
Copy link

github-actions bot commented Nov 26, 2024

7716 tests run: 7397 passed, 0 failed, 319 skipped (full report)


Flaky tests (7)

Postgres 17

Postgres 16

  • test_physical_replication_config_mismatch_max_locks_per_transaction: release-arm64
  • test_storage_controller_node_deletion[True]: release-x86-64

Code coverage* (full report)

  • functions: 31.5% (8362 of 26562 functions)
  • lines: 48.0% (66400 of 138398 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
adc8d2a at 2024-12-11T20:10:37.944Z :recycle:

Copy link
Contributor

@problame problame left a comment

Choose a reason for hiding this comment

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

It would make sense to express CompactOptions compact_below_lsn and compact_above_lsn as an unbounded range, instead of as two options.

Maybe fold them into CompactRange, so that CompactRange can represent the entire rectangle.

Please do that in a future PR though.


It would be nice to add a test that tests the interaction of key & lsn range limits, i.e., a test that tests behavior of specifying a full rectangle.

Maybe just copy-paste and adjust the test you added in this PR.


Definition of compact_above_lsn.
Above is kinda ambiguous wrt inclusivity vs exclusivity.

pageserver/src/tenant/timeline/compaction.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline/compaction.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/timeline/compaction.rs Outdated Show resolved Hide resolved
@skyzh skyzh force-pushed the skyzh/schedule-partial-compaction branch from 2077ba4 to 15f26fe Compare December 5, 2024 20:44
Base automatically changed from skyzh/schedule-partial-compaction to main December 6, 2024 18:46
@skyzh skyzh force-pushed the skyzh/gc-compaction-above-lsn branch 2 times, most recently from 4b01a48 to 233eebb Compare December 8, 2024 20:28
@skyzh
Copy link
Member Author

skyzh commented Dec 9, 2024

It would make sense to express CompactOptions compact_below_lsn and compact_above_lsn as an unbounded range, instead of as two options.

Included in 233eebb, where I did some refactors to make the compaction job desc more clear.

It would be nice to add a test that tests the interaction of key & lsn range limits, i.e., a test that tests behavior of specifying a full rectangle.

part of 20b6336

Definition of compact_above_lsn.

Comments are added in 233eebb. But actually, whether it's exclusive/inclusive doesn't actually matter because the compaction picker will not treat this input range as a definitive input -- it will change the lsn range based on the layer selection to avoid cut a layer in half.

@skyzh skyzh requested a review from problame December 9, 2024 02:08
skyzh and others added 7 commits December 9, 2024 16:18
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
Signed-off-by: Alex Chi Z <[email protected]>
@skyzh skyzh force-pushed the skyzh/gc-compaction-above-lsn branch from 98923e5 to 0ebfb1e Compare December 9, 2024 21:21
Signed-off-by: Alex Chi Z <[email protected]>
@skyzh skyzh force-pushed the skyzh/gc-compaction-above-lsn branch from eb4c6c7 to 3966318 Compare December 9, 2024 22:21
@skyzh skyzh force-pushed the skyzh/gc-compaction-above-lsn branch from 72b1bf1 to 6fa8592 Compare December 9, 2024 22:36
Copy link
Contributor

@problame problame 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 we need to track 4 rewritten layers now

  • above rectangle
  • below rectangle
  • left of rectangle
  • right of rectangle

desc.lsn_range.clone(),

Should have a test case for this before fixing.
I think the scenario is

  • base image layer
  • a 4-key-wide-4 lsn-tall delta layer on top
  • a 2-key-wide-2-lsn-tall compact_{key,lsn}_range

pageserver/src/tenant/timeline/compaction.rs Outdated Show resolved Hide resolved
@skyzh
Copy link
Member Author

skyzh commented Dec 11, 2024

above rectangle
below rectangle

The selection algorithm will not select an LSN that intersects with the layer, so we never need to rewrite those layers (and that's why they didn't get tracked)

Signed-off-by: Alex Chi Z <[email protected]>
@skyzh
Copy link
Member Author

skyzh commented Dec 12, 2024

Looking at the current code, the delta layer lsn range is generated as expected.

        let mut delta_layer_writer = SplitDeltaLayerWriter::new(
            self.conf,
            self.timeline_id,
            self.tenant_shard_id,
            lowest_retain_lsn..end_lsn,
            self.get_compaction_target_size(),
        )
        .await?;

Here lowest_retain_lsn = min_layer_lsn, and end_lsn = max_lsn. So the generated delta layer is actually min_layer_lsn..max_layer_lsn. This means that all current tests that checks layer key will ensure delta layers are created using the correct lsn range. We can merge the patch for now.

@skyzh skyzh enabled auto-merge December 12, 2024 20:06
@skyzh skyzh added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit 5ff4b99 Dec 12, 2024
83 checks passed
@skyzh skyzh deleted the skyzh/gc-compaction-above-lsn branch December 12, 2024 20:25
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