EXECUTIVE SUMMARY

PROBLEM

A Kafka processing pipeline could repeatedly stall when a malformed poison-pill record failed timestamp parsing. The error path invoked a synchronous remote partner-configuration API, which could exceed max.poll.interval.ms. This caused consumer-group rebalances and repeated delivery of the same record, allowing one invalid message to disrupt otherwise healthy processing. The failure was not adequately isolated at the record level, so a single malformed payload could trigger wider consumer instability and repeated processing attempts.

SOLUTION

The pipeline was redesigned to validate records at the processing boundary and isolate invalid payloads from the normal consumer path. Poison-pill messages were quarantined to transaction.dlq with their original payload and diagnostic information, while a separate consumer group and recovery workflow handled investigation and reprocessing. The recovery state was recorded in PostgreSQL using PENDING_REVIEW, preserving traceability without blocking the healthy processing path on synchronous remote calls.

CORE ARCHITECTURAL SHIFT

FROM poison-pill redelivery repeatedly disrupting the main consumer group
→
TO record-level quarantine and independent recovery without blocking healthy processing

CONCLUSION

Malformed records could be isolated for review without repeatedly disrupting the main consumer group. The design separated record-level failures from consumer, consumer-group, and platform-level failures, allowing recovery to proceed independently from normal processing. The result was a more contained failure path with preserved payloads and diagnostics, rather than repeated redelivery of a poison-pill record through the primary pipeline.

ARCHITECTURAL ANALYSIS

CONTEXT & BUSINESS IMPACT

The platform processes financial events for a multi-jurisdictional settlement, processing, and compliance environment. The pipeline handles approximately 1.5M–2.5M financial events per day through 8–12 Kafka partitions.

Normal traffic is approximately 20–30 messages per second per active partition. During bursts, aggregate traffic reaches approximately 350–500 messages per second across the active partitions.

Processing takes place within operationally sensitive settlement and compliance windows. Cross-border settlement, partner batch files, S3 ingestion, real-time financial transactions, and T+0 processing can be subject to strict timelines, with clearing and compliance activities operating within 15–30 minute windows.

A recurring pipeline freeze was therefore more than an individual record-processing error. When the same invalid record repeatedly triggered consumer-group rebalances, otherwise valid financial events were also exposed to interruptions in the primary processing flow.

Daily financial events

BEFORE 1.5M–2.5M
AFTER 1.5M–2.5M

Sustained high-volume financial event processing

Kafka partitions

BEFORE 8–12
AFTER 8–12

Partitioned event-processing topology

Normal throughput

BEFORE 20–30 msg/sec per active partition
AFTER 20–30 msg/sec per active partition

Normal operating traffic

Burst throughput

BEFORE 350–500 msg/sec aggregate
AFTER 350–500 msg/sec aggregate

Burst traffic across active partitions

THE POISON-PILL FAILURE

The failure originated with records containing malformed or ambiguous timestamps. When local information was insufficient to interpret a timestamp, processing could fall back to a synchronous remote partner configuration API.

This introduced an external blocking dependency directly into Kafka consumer processing. If the partner service stalled, a single record could keep processing blocked long enough to exceed the consumer's max.poll.interval.ms.

Once the polling interval was exceeded, Kafka consumer-group management could initiate a rebalance. Because the current record had not been successfully processed and committed, it could be assigned to another consumer.

The new consumer encountered the same record and could enter the same blocking path. A record-level failure was therefore capable of recurring across consumer assignments and interrupting the wider pipeline.

POISON-PILL REBALANCE CASCADE

MALFORMED / AMBIGUOUS MESSAGE
          |
          v
TIMESTAMP PROCESSING
          |
          v
SYNCHRONOUS REMOTE PARTNER API
          |
   REMOTE SERVICE STALL
          |
          v
PROCESSING EXCEEDS
max.poll.interval.ms
          |
          v
CONSUMER LEAVES GROUP
          |
          v
      REBALANCE
          |
          v
SAME UNCOMMITTED RECORD
          |
          v
RECORD ASSIGNED AGAIN
          |
          v
SAME FAILURE REPEATS
          |
          v
POISON-PILL REBALANCE CASCADE
          |
          v
PIPELINE INTERRUPTION

TWO FAILURE BOUNDARIES

The redesigned architecture establishes two distinct failure boundaries. Edge ingestion sanitization intercepts invalid input before it enters the primary processing path. Record-level dead-letter isolation handles failures that still occur during processing.

  1. Edge ingestion sanitization: validate structural schema, timestamp format, required fields, and partner-specific rules. Invalid input is quarantined before it can enter the primary pipeline.
  2. Record-level dead-letter isolation: if a record still fails during processing, route the failure to the dedicated transaction.dlq instead of performing blocking recovery work on the primary consumer path.

FAILURE ISOLATION BOUNDARIES

              EXTERNAL INPUT
                    |
                    v
              +----------------------------+
              | EDGE SANITIZATION          |
              |                            |
              | Schema validation          |
              | Timestamp validation       |
              | Required fields            |
              | Partner-specific rules     |
              +----------------------------+
                    |
         +----------+----------+
         |                     |
       VALID                 INVALID
         |                     |
         v                     v
  PRIMARY PIPELINE       EDGE QUARANTINE
         |
         v
  RECORD PROCESSING
         |
   +-----+-----+
   |           |
 SUCCESS     FAILURE
   |           |
   v           v
COMMIT     transaction.dlq
                |
                v
         RECOVERY WORKFLOW

NON-BLOCKING DEAD-LETTER ISOLATION

The primary Kafka consumer does not perform synchronous remote recovery or configuration lookups as part of record-failure handling. A record that fails during processing is routed to the dedicated transaction.dlq, separating the failure from the primary consumer's recovery workflow.

The dead-letter record preserves the information needed to identify the failure and trace the original event. This makes the failed record independently diagnosable and recoverable without repeatedly replaying the same failure through the primary consumer group.

  • x-error-class
  • x-original-topic
  • x-original-partition
  • x-original-offset
  • x-partner-id
  • x-trace-id
  • x-exception-message

A representative diagnostic record identifies an InvalidTimestampException for the payment.transactions.v1 topic, partition 3, offset 48190241, associated with partner PARTNER_EU_904 and trace identifier tr_b891a-89f4-421c. The diagnostic message is preserved as 'Unparseable timestamp'.

RECORD-LEVEL ISOLATION

    PRIMARY KAFKA CONSUMER
              |
              v
        PROCESS RECORD
              |
   +----------+----------+
   |                     |
 SUCCESS               FAILURE
   |                     |
   v                     v
COMMIT          transaction.dlq
   |                     |
   v                     v
CONTINUE         RECOVERY WORKFLOW
                         |
                         v
                  PENDING_REVIEW
                         |
                         v
                  CONTROLLED REPLAY

CONTROLLED RECOVERY & REPLAY

Dead-letter records are handled by a dedicated consumer group rather than the primary processing group. Recovery processing is therefore separated from the production event-processing path.

PostgreSQL records the recovery state as PENDING_REVIEW. The recovery record retains the original payload, source topic, partition and offset, partner identity, failure classification, diagnostics, and relevant timestamps.

  • Original event payload
  • Source Kafka topic
  • Source partition
  • Source offset
  • Partner identity
  • Failure classification
  • Failure diagnostics
  • Relevant timestamps
  • Recovery state: PENDING_REVIEW

Once the underlying problem has been understood or corrected, the record can enter a controlled replay workflow. Recovery becomes an explicit operational process rather than an accidental consequence of Kafka consumer-group reassignment.

RECOVERY WORKFLOW

transaction.dlq
      |
      v
DEDICATED RECOVERY GROUP
      |
      v
POSTGRESQL
PENDING_REVIEW
      |
      v
DIAGNOSTICS / CORRECTION
      |
      v
CONTROLLED REPLAY
      |
      v
PRIMARY PROCESSING FLOW

KEY ENGINEERING DECISIONS

  • Validate input at the edge so malformed records are intercepted before entering the primary processing path.
  • Keep blocking remote recovery work out of primary-consumer record-failure handling.
  • Isolate failed records individually instead of allowing one record to repeatedly destabilize the consumer group.
  • Route processing failures to the dedicated transaction.dlq and retain the source and diagnostic metadata needed for investigation.
  • Separate recovery into its own consumer group and operational workflow, with PENDING_REVIEW state persisted in PostgreSQL.
  • Use controlled replay to make recovery an explicit operation rather than relying on consumer-group reassignment.

These decisions establish distinct failure scopes. A record can fail without requiring the consumer, consumer group, or processing platform to fail with it. The architecture is designed to contain the failure at the narrowest practical boundary.

ARCHITECTURAL OUTCOME

The redesign changes the failure-propagation model. Invalid input is intercepted at ingestion where possible; records that fail during processing are isolated for separate recovery. Neither path is intended to make the lifetime of the primary consumer depend on repeated attempts to process the same failing record.

BEFORE

INVALID MESSAGE
      |
      v
BLOCKING PROCESSING
      |
      v
REMOTE DEPENDENCY STALL
      |
      v
max.poll.interval.ms EXCEEDED
      |
      v
CONSUMER-GROUP REBALANCE
      |
      v
SAME RECORD ASSIGNED AGAIN
      |
      v
REPEATED FAILURE
      |
      v
PIPELINE INTERRUPTION

AFTER

                INPUT
                  |
                  v
           EDGE SANITIZATION
                  |
         +--------+--------+
         |                 |
       VALID             INVALID
         |                 |
         v                 v
     PRIMARY          EDGE QUARANTINE
     PROCESSING
         |
   +-----+-----+
   |           |
 SUCCESS     FAILURE
   |           |
   v           v
COMMIT    transaction.dlq
               |
               v
       DEDICATED RECOVERY
               |
               v
       PENDING_REVIEW
               |
               v
       CONTROLLED REPLAY

The architectural improvement is not simply the addition of a dead-letter topic. It is the separation of failure lifetimes: a record can fail, be isolated, and require controlled recovery without that failure automatically propagating into the primary consumer group or the wider processing platform.

QUANTIFIED RESULTS

Pipeline freezes

BEFORE 1–2 significant freezes/month
AFTER 0 observed

Recurring poison-pill pipeline freezes were not observed during validation

Isolation / routing decision

BEFORE Blocking failure path
AFTER <10 ms

Measured record-level isolation and routing decision

Consumer rebalances

BEFORE Recurring during poison-pill failures
AFTER 0 observed

No poison-pill-induced consumer-group rebalances were observed during validation

Blocking consumer processing

BEFORE >300,000 ms
AFTER Non-blocking

The primary consumer no longer waits on the blocking failure-recovery path

Recovery

BEFORE Ad-hoc recovery
AFTER Controlled replay

Dead-letter records are handled through an explicit recovery workflow

Validation showed that the redesigned isolation and routing path could handle a failed record without relying on the previous blocking recovery path. The measured routing figure applies to the record-level isolation decision, not to a universal end-to-end processing guarantee.

In the previous failure mode, consumer processing could remain blocked beyond the five-minute scale represented by the measured duration. The redesigned path separates primary-consumer processing from dead-letter recovery.

The operational results distinguish observed behavior during validation from a universal guarantee about all future traffic and failure conditions.

The platform moved from implicit replay and poison-pill-induced consumer-group instability toward explicit record isolation, non-blocking primary processing, and controlled recovery. The key result is a narrower failure boundary: an invalid record becomes a recoverable operational item rather than repeatedly propagating its failure through the primary processing path.

ENGINEERING CONTRIBUTION

SWARCS performed end-to-end failure forensics and redesigned the Kafka processing boundaries to isolate malformed records and downstream processing failures without propagating them into primary consumer-group instability.

RESPONSIBILITIES

  • Analyze Kafka consumer behavior and recurring poison-pill failures.
  • Identify the blocking remote partner configuration call as a consumer-lifecycle risk.
  • Define edge sanitization for schema, timestamp, required-field, and partner-specific validation.
  • Introduce record-level dead-letter isolation through transaction.dlq.
  • Keep blocking recovery work out of primary-consumer record-failure handling.
  • Define DLQ metadata for error class, original topic, partition, offset, partner identity, trace identifier, and exception diagnostics.
  • Introduce the PostgreSQL PENDING_REVIEW recovery state.
  • Separate recovery processing into a dedicated consumer group and workflow.
  • Define controlled replay instead of relying on consumer-group reassignment for recovery.
  • Validate the isolation path and consumer-group behavior under poison-pill conditions.

KEY TAKEAWAY

INVALID INPUT MUST NEVER CONTROL THE LIFETIME OF A STREAM PROCESSOR.

Edge sanitization
Record-level failure isolation
Non-blocking consumer processing
Dead-letter queues
Dedicated recovery workflows
Controlled replay
Failure-scope separation
Kafka consumer stability

A bad message should produce a failed message, never a failed platform. The essential distinction is between record failure, consumer failure, consumer-group failure, and platform failure. By establishing explicit failure boundaries, isolating poison-pill records, and moving recovery outside the primary consumer path, invalid input becomes an operational recovery item instead of a distributed failure amplifier.