apache/seatunnel · warning
Error while closing pulsar consumer
Error message
Error while closing pulsar consumer
What it means
When the Pulsar split reader thread finishes (normally or after an error), it attempts to close the Pulsar consumer in a finally block. If that close itself throws, the thread logs this warning. It is a secondary cleanup failure — the original cause of the thread exiting is reported separately via handover.reportError.
Source
Thrown at seatunnel-connectors-v2/connector-pulsar/src/main/java/org/apache/seatunnel/connectors/seatunnel/pulsar/source/reader/PulsarSplitReaderThread.java:111
if (message != null) {
handover.produce(new RecordWithSplitId(message, split.splitId()));
if (stopCursor.shouldStop(message)) {
sourceReader.handleNoMoreElements(split.splitId(), message.getMessageId());
break;
}
} else {
Thread.sleep(pollInterval);
}
}
} catch (Throwable t) {
LOG.error("Pulsar Consumer receive data error", t);
handover.reportError(t);
} finally {
// make sure the PulsarConsumer is closed
try {
closeConsumer();
} catch (Throwable t) {
LOG.warn("Error while closing pulsar consumer", t);
} finally {
running = false;
}
}
}
@Override
public void close() throws IOException {
running = false;
closeConsumer();
}
public void committingCursor(MessageId offsetsToCommit) throws PulsarClientException {
if (consumer == null) {
consumer = createPulsarConsumer(split);
}
consumer.acknowledgeCumulative(offsetsToCommit);
}View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the logged Throwable cause ('t') for the underlying close failure (usually a broker connectivity or client-shutdown issue)
- Check broker availability and network stability at task shutdown time
- If it appears at every job stop, verify Pulsar client version and graceful shutdown ordering; update connector
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight broker reachability
if (!pulsarAdmin.serviceUrlReachable()) throw new IllegalStateException("Pulsar broker unreachable"); Try / catch
try { /* run job */ } catch (org.apache.seatunnel.api.table.type.SeaTunnelRuntimeException e) { /* inspect suppressed close warning cause for broker connectivity */ log.error("pulsar close failed: {}", e.getCause()); } Prevention
- Ensure broker is reachable during task shutdown
- Avoid cancelling tasks during Pulsar client reconnect storms
- Keep Pulsar client/connector versions aligned
- Monitor broker availability at stop-the-world moments
When it happens
Trigger: The split reader thread's run() loop exits (exception reported to handover or normal end) and closeConsumer() in the finally block throws any Throwable — e.g. Pulsar client already shut down, broker unreachable during close, or consumer already closed.
Common situations: Job/task cancellation racing with consumer close; Pulsar client connection lost at shutdown; an earlier reader exception left the consumer in a bad state that also fails on close.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Failed to close Pulsar admin.
- Error closing MQTT client
- Failed to close Pulsar consumer.
- CLOSE_CONNECTION_FAILED
- WRITER_CLOSE_FAILED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/8d8196567608bf4a.
Report an issue: GitHub.