Script icon
Process icon
If icon
SlackIncomingWebhook icon
Log icon
Return icon
Schedule icon

Apache Pinot Segment Unassigned and Reload Sentinel

Audits Apache Pinot tables to detect unassigned and errored segments, preventing real-time query degradation and missing data partitions.

Categories
DataInfrastructure

Apache Pinot powers mission-critical user-facing analytics and real-time dashboard applications. Network partitions, deep storage corruption, or server crashes can leave segments in unassigned, ERROR, or consuming dead-letter states where queries return incomplete query results or fail completely. This sentinel interrogates the Apache Pinot Controller REST API, verifies ideal states against external views across offline and real-time tables, and alerts data infrastructure teams on Slack with exact segment reload API commands.

How it works

  1. Scheduled triggering: Executes hourly at minute 0 (0 * * * *) using a cron schedule trigger or runs on-demand via manual execution and API webhooks.
  2. Table enumeration: Queries the Pinot Controller REST API (GET /tables) to discover all registered offline and real-time tables.
  3. Segment state analysis: Interrogates segment debug endpoints (/debug/tables/{tableName}/state) to detect mismatching ideal states, unassigned segments, and consuming errors.
  4. Condition evaluation: An io.kestra.plugin.core.flow.If task evaluates whether bad_segments_count exceeds max_tolerated_bad_segments.
  5. Slack alert dispatch: Sends high-priority incident details via SlackIncomingWebhook listing table names, segment identifiers, and exact reload commands.
  6. Audit trail logging and return: Emits operational execution logs and returns a structured health report containing complete segment diagnostic metadata.

Architecture diagram

flowchart TD
  A[hourly_pinot_segment_audit Schedule Trigger] --> B[scan_pinot_segments Python Script]
  B --> C[check_bad_segments Flowable If]
  C -- Degraded Segments Found --> D[notify_slack_pinot_ops Webhook]
  C -- All Segments Healthy --> E[log_pinot_segment_audit Log]
  D --> E
  E --> F[export_pinot_manifest Return]

Use cases

  • Real-time analytics reliability: Ensure streaming Kafka ingestion into Pinot real-time tables does not stall due to unassigned or broken consuming segments.
  • Offline batch ingestion validation: Catch data upload failures after batch Spark or MapReduce segment push jobs before analytical dashboards miss daily metrics.
  • Cluster rebalance verification: Confirm that all table segments are successfully reassigned to target Pinot servers following cluster scale-down or node upgrades.

Inputs

Name Type Default Description
pinot_controller_url STRING http://pinot-controller:9000 Base HTTP endpoint for the Apache Pinot cluster controller REST API.
table_name_filter STRING all Name of the Pinot table to audit, or all to scan all active offline and realtime tables.
alert_on_bad_segments BOOL true Whether to dispatch alerts when unassigned, offline, or errored segments are discovered.
max_tolerated_bad_segments INT 0 Maximum allowable count of degraded segments before triggering operational alerts.

Expected outputs

  • {{ outputs.scan_pinot_segments.vars.tables_scanned_count }}: Number of Pinot tables evaluated during the audit.
  • {{ outputs.scan_pinot_segments.vars.total_segments_audited }}: Consolidated count of segments inspected across all target tables.
  • {{ outputs.scan_pinot_segments.vars.bad_segments_count }}: Total number of degraded or unassigned segments flagged.
  • {{ outputs.scan_pinot_segments.vars.bad_segments_details }}: Serialized JSON list of degraded segments with curl reload commands.
  • {{ outputs.export_pinot_manifest.value }}: Structured dictionary containing the cluster segment health report.

Prerequisites

  • Network connectivity from Kestra execution workers to the Pinot Controller HTTP port (default 9000).
  • Optional bearer token or basic authentication credentials if Pinot Controller is secured behind reverse proxies.
  • Incoming Slack Webhook configured for data platform alerting.

Secrets

  • PINOT_CONTROLLER_TOKEN: Bearer token or API key for authenticating to the Pinot Controller.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL used for sending operational alerts.

Quick start

  1. Define PINOT_CONTROLLER_TOKEN and SLACK_WEBHOOK_URL in your Kestra Secret storage.
  2. Deploy this flow under the company.data namespace.
  3. Configure pinot_controller_url to point to your cluster controller (e.g., http://pinot-ctrl.internal:9000).
  4. Run a manual execution to test table discovery and verify alert routing.

Common pitfalls and troubleshooting

  • Real-time vs Offline table suffixes: Pinot appends _OFFLINE and _REALTIME to table names internally; ensure API calls handle both table types.
  • Helix znode state latency: Following cluster maintenance or server reboots, Helix state synchronization may take a few seconds before external view matches ideal state.
  • Deep storage download timeouts: If segment reload calls fail, verify that Pinot server nodes have direct network access and IAM credentials to the deep storage (S3, GCS, ADLS) backend.

How to extend

  • Automated segment reload trigger: Add a Kestra task that executes HTTP POST requests directly to /segments/{table}/{segment}/reload to automatically heal unassigned segments.
  • Kafka consumer lag correlation: Correlate real-time segment consumption errors with Kafka consumer lag metrics to distinguish broker issues from Pinot server faults.
  • PagerDuty on-call escalation: Escalate degraded segment alerts directly to on-call data platform engineers for business-critical real-time tables.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.