storage: correct source statistics for multi-replica clusters #32676
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, with sources running on multi-replica clusters (which are not
enabled in prod right now), we would overcount some metrics.
Specifically, there a gauge-metrics which would work correctly and there
are counter metrics where we would overcount. For example, each instance
of the source running on each replica would report
messages_received
.Now, we treat counter metrics differently: for those metrics where all
sources are reporting basically the same counter update we only take the
updates from the "first" replica. For gauges we just use all of them,
and the assumption is that these are largely the same on all replicas.
The one counter metric that is treated different from the others is
updates_committed
: only one replica will manage to commit updates, sowe have to make sure we take this counter in from all replicas, to
capture all messages that have been committed.
Implements https://github.com/MaterializeInc/database-issues/issues/9010
WIP: @def- I still need to add a test that has sources and multi-replica clusters.