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

[v23.3.x] [CORE-2161] cloud_storage/topic_manifest: force negative retention to mean infinite retention #18242

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/v/cloud_storage/tests/topic_manifest_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,17 @@ SEASTAR_THREAD_TEST_CASE(topic_manifest_min_serialization) {
auto rstr = make_iobuf_input_stream(std::move(buf));
topic_manifest restored;
restored.update(std::move(rstr)).get();
BOOST_REQUIRE(m == restored);
BOOST_CHECK_EQUAL(m.get_revision(), restored.get_revision());
auto restored_cfg = restored.get_topic_config().value();
// as a safety net, negative values for retention_duration are converted to
// disabled tristate (infinite retention)
BOOST_CHECK(restored_cfg.properties.retention_duration.is_disabled());

BOOST_CHECK_EQUAL(
restored_cfg.properties.retention_bytes,
min_cfg.properties.retention_bytes);
BOOST_CHECK_EQUAL(
restored_cfg.properties.segment_size, min_cfg.properties.segment_size);
}

SEASTAR_THREAD_TEST_CASE(topic_manifest_max_serialization) {
Expand Down Expand Up @@ -359,11 +369,9 @@ SEASTAR_THREAD_TEST_CASE(test_negative_property_manifest) {
BOOST_REQUIRE_EQUAL(64, tp_cfg->partition_count);
BOOST_REQUIRE_EQUAL(6, tp_cfg->replication_factor);
auto tp_props = tp_cfg->properties;
BOOST_REQUIRE(tp_props.retention_duration.has_optional_value());
BOOST_REQUIRE_EQUAL(
tp_props.retention_duration.value().count(), -36000000000);

// The usigned types that were passed in negative values shouldn't be set.
// The unsigned types that were passed in negative values shouldn't be set.
BOOST_REQUIRE(tp_props.retention_duration.is_disabled());
BOOST_REQUIRE(tp_props.retention_bytes.is_disabled());
BOOST_REQUIRE(!tp_props.segment_size.has_value());
}
Expand Down
7 changes: 5 additions & 2 deletions src/v/cloud_storage/topic_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,12 @@ struct topic_manifest_handler
_properties.retention_bytes = tristate<size_t>{
disable_tristate};
} else if (_key == "retention_duration") {
// even though a negative number is valid for milliseconds,
// interpret any negative value as a request for infinite
// retention, that translates to a disabled tristate (like for
// retention_bytes)
_properties.retention_duration
= tristate<std::chrono::milliseconds>(
std::chrono::milliseconds(i));
= tristate<std::chrono::milliseconds>(disable_tristate);
} else {
return false;
}
Expand Down
Loading