Skip to content

Commit 576a2b3

Browse files
Merge remote-tracking branch 'up/master' into fix-python-fn-nack-delay
# Conflicts: # pulsar-functions/instance/src/test/python/test_python_instance.py
2 parents 2c23d1a + 8a6f25b commit 576a2b3

55 files changed

Lines changed: 2997 additions & 209 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
name: CI - Python Functions
21+
on:
22+
pull_request:
23+
branches:
24+
- master
25+
paths:
26+
- '.github/workflows/**'
27+
- 'pulsar-functions/instance/src/main/python/**'
28+
- 'pulsar-functions/instance/src/test/python/**'
29+
- 'pulsar-functions/instance/src/scripts/**'
30+
workflow_dispatch:
31+
32+
concurrency:
33+
group: ${{ github.workflow }}-${{ github.ref }}
34+
cancel-in-progress: true
35+
36+
jobs:
37+
preconditions:
38+
name: Preconditions
39+
runs-on: ubuntu-24.04
40+
outputs:
41+
docs_only: ${{ steps.check_changes.outputs.docs_only }}
42+
steps:
43+
- name: checkout
44+
uses: actions/checkout@v6
45+
46+
- name: Detect changed files
47+
id: changes
48+
uses: apache/pulsar-test-infra/paths-filter@master
49+
with:
50+
filters: .github/changes-filter.yaml
51+
list-files: csv
52+
53+
- name: Check changed files
54+
id: check_changes
55+
run: |
56+
if [[ "${GITHUB_EVENT_NAME}" != "schedule" ]]; then
57+
echo "docs_only=${{ fromJSON(steps.changes.outputs.all_count) == fromJSON(steps.changes.outputs.docs_count) && fromJSON(steps.changes.outputs.docs_count) > 0 }}" >> $GITHUB_OUTPUT
58+
else
59+
echo docs_only=false >> $GITHUB_OUTPUT
60+
fi
61+
62+
- name: Check if the PR is ready for running CI
63+
if: ${{ steps.check_changes.outputs.docs_only != 'true' && github.repository == 'apache/pulsar' && github.event_name == 'pull_request' }}
64+
uses: ./.github/actions/check-pr-ready-to-test
65+
66+
instance-tests:
67+
needs: preconditions
68+
if: ${{ needs.preconditions.outputs.docs_only != 'true' }}
69+
name: Python ${{ matrix.python-version }} Functions instance tests
70+
runs-on: ubuntu-24.04
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
python-version: ['3.12', '3.13']
75+
76+
steps:
77+
- name: checkout
78+
uses: actions/checkout@v6
79+
80+
- name: Tune Runner VM
81+
uses: ./.github/actions/tune-runner-vm
82+
83+
- name: Set up Python
84+
uses: actions/setup-python@v6
85+
with:
86+
python-version: ${{ matrix.python-version }}
87+
88+
- name: Run Python instance tests
89+
run: |
90+
./pulsar-functions/instance/src/scripts/run_python_instance_tests.sh

conf/broker.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,12 @@ exposeBundlesMetricsInPrometheus=false
20212021
# Default is false.
20222022
exposeCustomTopicMetricLabelsEnabled=false
20232023

2024+
# Enable computing the age of the oldest unacknowledged message for each subscription and exposing it
2025+
# through topic stats and Prometheus.
2026+
# When disabled, the broker skips computing per-subscription backlog age and the admin API field
2027+
# SubscriptionStats.oldestBacklogMessageAgeSeconds remains -1. Default is false.
2028+
exposeSubscriptionBacklogAgeInPrometheus=false
2029+
20242030
# A comma-separated list of Topic Property keys that are allowed to be exposed as metrics.
20252031
# Only these keys can be set as custom metric labels on topics.
20262032
# Example: sla_tier,data_sensitivity,cost_center,app_owner

conf/standalone.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,12 @@ exposePublisherStats=true
12901290
# Default is false.
12911291
exposePreciseBacklogInPrometheus=false
12921292

1293+
# Enable computing the age of the oldest unacknowledged message for each subscription and exposing it
1294+
# through topic stats and Prometheus.
1295+
# When disabled, the broker skips computing per-subscription backlog age and the admin API field
1296+
# SubscriptionStats.oldestBacklogMessageAgeSeconds remains -1. Default is false.
1297+
exposeSubscriptionBacklogAgeInPrometheus=false
1298+
12931299
# Enable splitting topic and partition label in Prometheus.
12941300
# If enabled, a topic name will split into 2 parts, one is topic name without partition index,
12951301
# another one is partition index, e.g. (topic=xxx, partition=0).

pip/pip-382.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Pulsar has a metric that indicates load topic failed: `topic_load_failed_total`, it will be increased at the following cases
66
- The target bundle in unloading.
7-
- Failed to load policies.
7+
- Failed to load namespace-level or topic-level policies.
88
- Failed to load up Managed Ledger.
99
- Failed to read Metadata store.
1010
- Topic initialize fails, such as failed to re-build deduplication info.
@@ -21,13 +21,47 @@ Add a label named reason for topic_load_failed_total
2121
- label name: `reason`
2222
- label values:
2323
- `bundle_unloading`
24-
- `failed_load_policies`
24+
- `failed_load_namespace_policies`
25+
- `failed_load_topic_policies`
2526
- `failed_load_ml`
27+
- `failed_check_ownership`
2628
- `failed_access_metadata_store`
2729
- `failed_init`
28-
- `timeout`
30+
- `timeout` (generic timeout, or timeout while more than one loading stage is pending)
31+
- `timeout_load_namespace_policies`
32+
- `timeout_load_topic_policies`
33+
- `timeout_load_ml`
34+
- `timeout_init`
35+
- `timeout_dedup`
2936
- `others`
3037

38+
### Implementation Notes
39+
40+
Each persistent topic-loading operation records at most one failure. The failure reason is attached at the
41+
operation that can identify it, rather than by wrapping exceptions solely for metrics. The final topic future
42+
increments the counter once, so callers that reuse an in-flight load future do not create additional samples.
43+
44+
Timeouts describe the loading stage that is still pending when the timeout fires:
45+
46+
| Pending stage | Timeout reason |
47+
|---|---|
48+
| namespace-level policy loading, including during `PersistentTopic` initialization | `timeout_load_namespace_policies` |
49+
| topic-level policy loading, including during `PersistentTopic` initialization | `timeout_load_topic_policies` |
50+
| opening the managed ledger | `timeout_load_ml` |
51+
| topic initialization, replication, or compacted-subscription setup | `timeout_init` |
52+
| deduplication initialization | `timeout_dedup` |
53+
| no single pending stage | `timeout` |
54+
55+
`bundle_unloading` includes failures while a bundle is unloading and failures because this broker is not the
56+
topic owner. `TopicMigratedException` is an expected migration control flow and does not increment
57+
`topic_load_failed_total`.
58+
59+
`failed_check_ownership` covers failures while resolving the namespace bundle or checking its ownership. A
60+
successful ownership check that determines this broker is not the owner is reported as `bundle_unloading`.
61+
62+
`brk_topic_load_failed_count` remains available for compatibility and is the sum of all reason-labelled failure
63+
series.
64+
3165

3266
# Monitoring & Alternatives
3367

0 commit comments

Comments
 (0)