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

storage: fix bounds check in offset range size method #24880

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

andrwng
Copy link
Contributor

@andrwng andrwng commented Jan 22, 2025

The methods to find offset range size currently use segment bounds to
determine whether a given offset is available to be queried. This
doesn't account for the case when the segment set contains offsets that
don't fall in the log's offset range (e.g. follow a delete records
request that trims mid-segment).

This commit adds appropriate bounds checks to both methods.

With an upcoming change to merge compact after windowed compaction,
test_offset_range_size2_compacted would fail because it would prefix
truncate mid-segment following a merge compaction, and then trip over
this, hitting an unexpected exception when creating a reader:

```
std::runtime_error: Reader cannot read before start of the log 0 < 887
```

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v24.3.x
  • v24.2.x
  • v24.1.x

Release Notes

  • None

The test itself has many steps that make it hard to follow what has
happened. Adds some log messages to indicate different steps in the
test.
Adds a static constructor to return an optional interval, which per the
class comments, should represent an empty interval.

I intend on using this for some upcoming bounds checks.
The methods to find offset range size currently use segment bounds to
determine whether a given offset is available to be queried. This
doesn't account for the case when the segment set contains offsets that
don't fall in the log's offset range (e.g. follow a delete records
request that trims mid-segment).

This commit adds appropriate bounds checks to both methods.

With an upcoming change to merge compact after windowed compaction,
test_offset_range_size2_compacted would fail because it would prefix
truncate mid-segment following a merge compaction, and then trip over
this, hitting an unexpected exception when creating a reader:

```
std::runtime_error: Reader cannot read before start of the log 0 < 887
```
@vbotbuildovich
Copy link
Collaborator

CI test results

test results on build#61022
test_id test_kind job_url test_status passed
rptest.tests.partition_balancer_test.PartitionBalancerTest.test_unavailable_nodes ducktape https://buildkite.com/redpanda/redpanda/builds/61022#01948c34-e8b6-4eb6-bc9f-eea76be5e1bc FLAKY 1/2

Copy link
Contributor

@Lazin Lazin left a comment

Choose a reason for hiding this comment

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

Didn't know about bounded_offset_interval. Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants