-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
archival: consistent log size probes across replicas
We called update probe only from leaders and after exiting the upload loop which led to inconsistent and stale metrics. Fix this by introducing a subscription mechanism to the STM which is the source of truth for the manifest state and must be consistent across all replicas. Another option is to report metrics only from the leader :think:
- Loading branch information
1 parent
1d42061
commit 734375b
Showing
7 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
#pragma once | ||
|
||
#include "base/seastarx.h" | ||
#include "cluster/archival/stm_subscriptions.h" | ||
#include "utils/named_type.h" | ||
|
||
#include <seastar/util/noncopyable_function.hh> | ||
|
||
#include <absl/container/flat_hash_map.h> | ||
|
||
#include <cstdint> | ||
|
||
namespace archival { | ||
|
||
/// A class that allows to subscribe to state changes in the archival metadata | ||
/// STM. | ||
class stm_subscriptions { | ||
public: | ||
using id_t = named_type<int32_t, struct id_tag>; | ||
|
||
id_t subscribe(ss::noncopyable_function<void() noexcept> f) { | ||
auto id = _next_sub_id++; | ||
_subscriptions.emplace(id, std::move(f)); | ||
return id; | ||
} | ||
|
||
void unsubscribe(id_t id) { _subscriptions.erase(id); } | ||
|
||
void notify() { | ||
for (auto& [_, f] : _subscriptions) { | ||
f(); | ||
} | ||
} | ||
|
||
private: | ||
absl::flat_hash_map<id_t, ss::noncopyable_function<void() noexcept>> | ||
_subscriptions; | ||
id_t _next_sub_id{0}; | ||
}; | ||
|
||
}; // namespace archival |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters