Skip to content

Messaging: configurable topic sample count with bounded polling - #39888

Open
Khairajani wants to merge 5 commits into
mainfrom
fix/messaging-sample-count
Open

Khairajani wants to merge 5 commits into
mainfrom
fix/messaging-sample-count

Conversation

@Khairajani

@Khairajani Khairajani commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#8191

Topic sample data in the messaging metadata workflow now samples a configurable number of messages, and every source stops at a defined bound.

  • New setting sampleDataCount on the messaging metadata pipeline: default 10 (the old fixed sample), 1–1000.
  • Kafka/Redpanda: only messages that decode count. Consumer errors, poll exceptions, tombstones (stored as "None" before) and undecodable payloads are skipped. The 10s polling deadline per topic stays, and sampling stops after 3 consecutive poll exceptions.
  • Kinesis: each get_records call passes Limit. Sampling continues across shards until the count is met and follows at most 5 pages per shard. Before this, one call could return up to 10k records, and sampling stopped after the first shard.
  • NATS: samples the configured count; the scan window grows to max(100, 2 × count).
  • Pub/Sub: still not sampled; the field description says so.
  • Auto-classification samplers: unchanged. They already honour their own sampleDataCount.
  • Decision record: ADR:2026-12-05-messaging-sample-data-counts-decoded-messages-within-a-per-topic-bound.

Type of change:

  • Improvement

High-level design:

N/A: an additive schema field with a default that keeps current behaviour. The bounds are in the decision record.

Tests:

Which test layer and why

Python unit tests. The consumer, Kinesis and NATS clients are scripted, so the counts and bounds are checked without a broker.

Use cases covered

  • Kafka stops at the configured count and goes past the old 10 when asked.
  • A sparse topic returns what it has, and an empty topic stops at the deadline.
  • Errors, exceptions, tombstones and undecodable payloads don't count toward the sample.
  • A failing subscribe is reported and stores an empty sample.
  • Kinesis limits each read, reads further shards, follows empty pages up to the cap, and returns what it read when a call fails, including a throttled read partway through a shard.
  • NATS samples the configured count, including counts above the old scan window.
  • The setting defaults to 10 and rejects 0, -1 and 1001.

Unit tests

  • Added ingestion/tests/unit/source/messaging/test_sample_count.py (25 tests).
  • Tests fail first: with main's source and this schema, 13 of the first 24 fail on behaviour (short samples, "None" tombstones, 50 Kinesis records instead of 10). The 25th, added after review, failed on the previous commit: a throttled second page dropped the shard's first page. All 25 pass on this branch.
  • 416 passed across tests/unit/source/messaging/ and tests/unit/sampler/.

Backend integration tests

  • Not applicable (no API changes). The focused plan selected no tests, so I added IngestionPipelineResourceIT because it stores pipeline configs: 278 run, 0 failures, 28 skipped (mysql-elasticsearch).

Local Java test run: PASSED

  • Commit: c12f52cf8e01 (base origin/main)
  • Finished: 2026-12-05 18:46 UTC · 3.9 min
  • Details: the classes each step ran, why these tests, the commands
  • Scope: focused; merge readiness is not established. Broader steps deferred: 2 (run --scope full).
Step Scope Classes Tests Failed Skipped Min Result
integration mysql-elasticsearch · parallel 1 278 0 28 3.9 passed

Ingestion integration tests

  • Not run against a real broker: pending.

Playwright (UI) tests

  • Not applicable. The form field is rendered from the regenerated schema; I haven't checked it in a running UI.

Manual testing performed

None beyond the tests above.

UI screen recording:

Not applicable: an ingestion setting rendered automatically from the schema, with no UI code change.

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: no migration needed. The field is optional with a default, and existing pipelines keep sampling 10.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: added docs/decisions/2026-12-05-messaging-sample-data-counts-decoded-messages-within-a-per-topic-bound.md.

🤖 Generated with Claude Code

…ithin a bound

Add sampleDataCount (default 10, 1-1000) to the messaging metadata pipeline.
Kafka/Redpanda count only decoded messages against it, skipping consumer
errors, poll exceptions, tombstones and undecodable payloads, within the
10-second per-topic deadline and after 3 consecutive poll failures. Kinesis
passes Limit, reads further shards to reach the count, and follows at most
5 pages per shard. NATS samples the configured count and widens its scan
window with it.
@Khairajani
Khairajani requested a review from a team as a code owner December 5, 2026 18:42
@Khairajani
Khairajani requested review from harshsoni2024 and removed request for a team December 5, 2026 18:42
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@Khairajani

Copy link
Copy Markdown
Contributor Author

Local Java test run: PASSED — details

  • Commit: c12f52cf8e01 (base origin/main)
  • The summary is in the PR description.

Tests run locally

  • integration · mysql-elasticsearch · parallel: IngestionPipelineResourceIT (250 passed, 28 skipped)

Broader coverage not executed by this focused run

  • mvn -B verify -pl :openmetadata-integration-tests -am -DskipBootJar=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel '-Dit.test=<31 classes>' -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
  • mvn -B verify -pl :openmetadata-integration-tests -am -DskipBootJar=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=PipelineStatusPaginationSqlIT,WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false
Why these tests
  • added by author: messagingServiceMetadataPipeline gains sampleDataCount; the server stores and returns pipeline sourceConfig ← IngestionPipelineResourceIT
Commands
mvn -B verify -pl :openmetadata-integration-tests -am -DskipBootJar=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=IngestionPipelineResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false

@gitar-bot

gitar-bot Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findings

Configurable per-topic sampling changes broker reads and stored samples; requesting up to 1,000 messages could increase ingestion work.

Adds a configurable sampleDataCount (default 10, range 1-1000) for topic sample data across messaging sources, with Kafka/Redpanda counting only decoded messages under a 10s deadline, Kinesis sampling across shards with per-read limits and a 5-page cap per shard, and NATS sampling the configured count. Resolved: Kinesis no longer drops a shard's earlier pages when a later get_records call fails. No open issues found.

✅ 1 closed
✅ Edge Case: Kinesis drops a shard's earlier pages when a later get_records fails

📄 ingestion/src/metadata/ingestion/source/messaging/kinesis/metadata.py:226-234 📄 ingestion/src/metadata/ingestion/source/messaging/kinesis/metadata.py:236-250
_sample_shard builds its records in a local data list and returns it only after the page loop ends. If a later get_records call raises, for example ProvisionedThroughputExceededException (Kinesis allows 5 reads per second per shard, and this loop can make 5 calls back to back), the exception goes up to _get_sample_data. That method catches it, but the records already read from that shard's earlier pages are lost. This goes against the PR's promise that Kinesis "return[s] what was read when a call fails". The current test only covers a failure in get_shard_iterator on a second shard, so it does not catch this. Fix: catch the error per page inside _sample_shard and return the partial data, or pass the caller's list in so records are added as each page arrives.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant