-
Notifications
You must be signed in to change notification settings - Fork 552
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
Offset tracker invariants #17381
Offset tracker invariants #17381
Conversation
ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/46740#018e7817-8b0f-460a-80a9-b5312b34a560 ducktape was retried in https://buildkite.com/redpanda/redpanda/builds/46740#018e7823-f542-4138-8ffc-12448c07670a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me. i think a little commit history clean up is all that is needed.
src/v/storage/segment.h
Outdated
(set_offset_impl(std::forward<Ts>(ts)), ...); | ||
vassert( | ||
_committed_offset <= _stable_offset && _stable_offset <= _dirty_offset, | ||
"Must maintain offset invariant: committed <= stable <= dirty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print out the values in the assertion failure to aid in debugging
src/v/storage/segment.h
Outdated
, _dirty_offset(model::prev_offset(base)) {} | ||
|
||
template<typename... Ts> | ||
void set_offsets(Ts&&... ts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this looks fine, but I think you can remove all the forwarding references and pass around T
values. the model::offset types are just a single integer / trivially copyable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair! Forwarding references changed to pass by value.
src/v/archival/archival_policy.cc
Outdated
@@ -285,7 +285,9 @@ static ss::future<std::optional<std::error_code>> get_file_range( | |||
upl->final_file_offset = fsize; | |||
upl->base_timestamp = segment->index().base_timestamp(); | |||
upl->max_timestamp = segment->index().max_timestamp(); | |||
if (!end_inclusive && segment->offsets().get_base_offset() == begin_inclusive) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the two reformatting commits can be squashed together.
src/v/storage/segment.h
Outdated
static_assert(sizeof(T) && false, "Invalid offset type"); | ||
static_assert(always_false_v<T>, "Invalid offset type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be squashed back into the original commit
src/v/storage/segment.h
Outdated
//_tracker.committed_offset = _idx.max_offset(); | ||
//_tracker.stable_offset = _idx.max_offset(); | ||
//_tracker.dirty_offset = _idx.max_offset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be squashed back into the original commit
storage_resources resources; | ||
}; | ||
|
||
TEST_F(segment_offset_tracker_fixture, get_and_set_offsets) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
cluster: remove unnecessary virtual specifier cloud_storage: removal of extra forward declaration
808a3c4
to
ef97c40
Compare
model::term_id get_term() const { return _term; } | ||
model::offset get_base_offset() const { return _base_offset; } | ||
model::offset get_committed_offset() const { return _committed_offset; } | ||
model::offset get_stable_offset() const { return _stable_offset; } | ||
model::offset get_dirty_offset() const { return _dirty_offset; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these accessors need to be in the previous commit so that the previous commit will compile.
ef97c40
to
a58bc90
Compare
set_offsets(t); | ||
} | ||
|
||
model::term_id get_term() const { return _term; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: get_
prefix is just noise to me. I suggest we name them just term()
, base_offest()
in the future. @dotnwat wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nvartolomei yes, I think get_
is too verbose. If we want a prefix, I think using it for set_
is better as it is generally used far less.
Maybe bring it up in core storage and we can agree on a style and then change this depending on the outcome?
, _dirty_offset(model::prev_offset(base)) {} | ||
|
||
template<typename... Ts> | ||
void set_offsets(Ts... ts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat & clever! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we also have a mean of enforcing that offsets don't move backwards? Unless it is a call to truncate?
Changed
storage::segment::offset_tracker
from astruct
to aclass
, made data fields private.Added public "getter" and "setter" functions in order to
vassert
the necessary offset invariants.Also packaged in some very minor changes (see commit
85d979bd79f7a9e41cb83237673f483c25e02ac1
), includingpartition_probe
forward declaration incloud_storage/fwd.h
static constexpr
variable incluster/cloud_storage_size_reducer.h
virtual
specifier on a member function of a class markedfinal
incluster/id_allocator.h
Backports Required
Release Notes