-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[improve][pip] PIP-441: Add Broker-Level Metrics for Skipped Non-Recoverable Data #24716
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
Open
codelipenghui
wants to merge
2
commits into
apache:master
Choose a base branch
from
codelipenghui:pip-441-broker-metrics-non-recoverable-data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,115 @@ | ||
| # PIP-441: Add Broker-Level Metrics for Skipped Non-Recoverable Data | ||
|
|
||
| # Background knowledge | ||
|
|
||
| Pulsar's `autoSkipNonRecoverableData` feature allows brokers to skip corrupted data during disaster recovery to maintain topic availability. The system uses two skip strategies: | ||
|
|
||
| 1. **Ledger-level skipping**: Skips entire ledgers when completely unrecoverable | ||
| 2. **Entry-level skipping**: Skips specific entries within a ledger when only partially corrupted | ||
|
|
||
| The entry level skipping was introduced in PIP-327 and refined in [PR #17753](https://github.com/apache/pulsar/pull/17753) to handle scenarios like ledger corruption, bookie failures, and partial data loss. | ||
|
|
||
| # Motivation | ||
|
|
||
| Currently, there is no visibility into when and how frequently non-recoverable data is being skipped, creating operational challenges: | ||
|
|
||
| - **No alerting capability** when data loss occurs | ||
| - **No audit trail** for compliance and data integrity requirements | ||
| - **Cannot distinguish** between healthy systems and those silently skipping data | ||
| - **Cannot determine** if data loss is wholesale (ledgers) or partial (entries) | ||
| - **Limited capacity planning** without understanding failure patterns | ||
|
|
||
| # Goals | ||
|
|
||
| ## In Scope | ||
|
|
||
| Add two broker-level metrics: | ||
| - `pulsar_broker_non_recoverable_ledgers_skipped_total` - Count of ledgers skipped | ||
| - `pulsar_broker_non_recoverable_entries_skipped_total` - Count of entries skipped | ||
|
|
||
| ## Out of Scope | ||
|
|
||
| - Topic/subscription-level metrics (would burden metrics system with high cardinality) | ||
| - Historical tracking of specific ledgers/entries skipped | ||
| - Changes to existing `autoSkipNonRecoverableData` functionality | ||
|
|
||
| # High Level Design | ||
|
|
||
| Two broker-level counters will be added to `BrokerOperabilityMetrics`: | ||
|
|
||
| - **Ledger counter**: Incremented in `ManagedLedgerImpl.skipNonRecoverableLedger()` | ||
| - **Entry counter**: Incremented in `ManagedCursorImpl.skipNonRecoverableEntries()` | ||
|
|
||
| Both metrics are exposed via the existing Prometheus `/metrics` endpoint. | ||
|
|
||
| # Detailed Design | ||
|
|
||
| ## Implementation Details | ||
|
|
||
| **BrokerOperabilityMetrics Changes:** | ||
| ```java | ||
| private final LongAdder nonRecoverableLedgersSkippedCount; | ||
| private final LongAdder nonRecoverableEntriesSkippedCount; | ||
|
|
||
| public void recordNonRecoverableLedgerSkipped() { | ||
| this.nonRecoverableLedgersSkippedCount.increment(); | ||
| } | ||
|
|
||
| public void recordNonRecoverableEntriesSkipped(long entriesCount) { | ||
| this.nonRecoverableEntriesSkippedCount.add(entriesCount); | ||
| } | ||
| ``` | ||
|
|
||
| **Integration Points:** | ||
| - `ManagedLedgerImpl.skipNonRecoverableLedger()` → calls `recordNonRecoverableLedgerSkipped()` | ||
| - `ManagedCursorImpl.skipNonRecoverableEntries()` → calls `recordNonRecoverableEntriesSkipped(count)` | ||
|
|
||
| **OpenTelemetry Support:** | ||
| - `pulsar.broker.non_recoverable_ledger.skip.count` | ||
| - `pulsar.broker.non_recoverable_entries.skip.count` | ||
|
|
||
| ## Public-facing Changes | ||
|
|
||
| ### Metrics | ||
|
|
||
| | Metric Name | Description | Type | | ||
| |-------------|-------------|------| | ||
| | `pulsar_broker_non_recoverable_ledgers_skipped_total` | Count of ledgers skipped when `autoSkipNonRecoverableData` enabled | Counter | | ||
| | `pulsar_broker_non_recoverable_entries_skipped_total` | Count of entries skipped when `autoSkipNonRecoverableData` enabled | Counter | | ||
|
|
||
| **Labels:** `broker`, `cluster` | ||
|
|
||
| # Monitoring | ||
|
|
||
| **Use Cases:** | ||
| - **Alerting**: Get notified when data loss occurs | ||
| - **SLA Monitoring**: Track data durability metrics | ||
| - **Root Cause Analysis**: Compare metrics to understand if issues are systematic (ledger-level) or localized (entry-level) | ||
| - **Investigation**: Use metrics for alerting, then check broker logs for specific topic details | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broker logs can pinpoint which specific topic is having an issue. |
||
|
|
||
| **Example Alerts:** | ||
| ```prometheus | ||
| # Alert on any data loss | ||
| increase(pulsar_broker_non_recoverable_ledgers_skipped_total[5m]) > 0 or | ||
| increase(pulsar_broker_non_recoverable_entries_skipped_total[5m]) > 0 | ||
| ``` | ||
|
|
||
| # Backward & Forward Compatibility | ||
|
|
||
| - **Upgrade**: No special procedures required. Metrics start at 0. | ||
| - **Downgrade**: Fully backward compatible. Metrics simply stop being exposed. | ||
| - **Geo-Replication**: No impact. Each broker maintains its own counts. | ||
|
|
||
| # Alternatives | ||
|
|
||
| - **Topic-level metrics**: Rejected due to high cardinality burden on metrics system. Use broker metrics for alerting, then check logs for specific topics. | ||
| - **Single combined metric**: Rejected as separate ledger/entry metrics provide better operational insights. | ||
|
|
||
| # Summary | ||
|
|
||
| This PIP adds essential observability for the existing `autoSkipNonRecoverableData` feature without changing its behavior. The broker-level approach balances operational visibility with system performance by avoiding high-cardinality metrics. | ||
|
|
||
| # Links | ||
|
|
||
| * Mailing List discussion thread: https://lists.apache.org/thread/b638towc7o4qb8dsozys4c14s00yflfj | ||
| * Mailing List voting thread: https://lists.apache.org/thread/t461899qf878j4wr7wfhomkhw67vorjp | ||
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.
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.
How about in-memory topic & subscription stats?
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.
Yes, that makes sense.