{"record":{"id":"84dee32bc9a01b60","repo":"alibaba/canal","slug":"failed-to-fetch-the-data-after-timeout-84dee3","errorCode":null,"errorMessage":"Failed to fetch the data after: {timeout}","messagePattern":"Failed to fetch the data after: (.+?)","errorType":"exception","errorClass":"CanalClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/otter/canal/client/rocketmq/RocketMQCanalConnector.java","lineNumber":242,"sourceCode":"        }\n        return messages;\n    }\n\n    @Override\n    public List<Message> getListWithoutAck(Long timeout, TimeUnit unit) throws CanalClientException {\n        try {\n            if (this.lastGetBatchMessage != null) {\n                throw new CanalClientException(\"mq get/ack not support concurrent & async ack\");\n            }\n\n            ConsumerBatchMessage batchMessage = messageBlockingQueue.poll(timeout, unit);\n            if (batchMessage != null) {\n                this.lastGetBatchMessage = batchMessage;\n                return batchMessage.getData();\n            }\n        } catch (InterruptedException ex) {\n            logger.warn(\"Get message timeout\", ex);\n            throw new CanalClientException(\"Failed to fetch the data after: \" + timeout);\n        }\n        return Lists.newArrayList();\n    }\n\n    @Override\n    public List<FlatMessage> getFlatList(Long timeout, TimeUnit unit) throws CanalClientException {\n        List<FlatMessage> messages = getFlatListWithoutAck(timeout, unit);\n        if (messages != null && !messages.isEmpty()) {\n            ack();\n        }\n        return messages;\n    }\n\n    @Override\n    public List<FlatMessage> getFlatListWithoutAck(Long timeout, TimeUnit unit) throws CanalClientException {\n        try {\n            if (this.lastGetBatchMessage != null) {\n                throw new CanalClientException(\"mq get/ack not support concurrent & async ack\");","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client/src/main/java/com/alibaba/otter/canal/client/rocketmq/RocketMQCanalConnector.java#L224-L260","documentation":"Thrown by RocketMQCanalConnector.getListWithoutAck when the blocking queue poll is interrupted (InterruptedException) while waiting for a batch. The connector converts interruption into a CanalClientException naming the timeout. This indicates thread interruption, not a benign empty-poll timeout (which returns an empty list).","triggerScenarios":"Thread.interrupt() invoked on the consumer thread during poll; executor shutdown; container shutdown that interrupts worker threads; calling disconnect concurrently.","commonSituations":"Application shutdown interrupting the consumer thread; running inside a managed thread pool that cancels tasks; tests that time out and interrupt the consumer.","solutions":["Detect expected shutdown interruptions and exit the loop gracefully.","Restore interrupt flag in the catch and propagate only if unexpected.","Ensure disconnect happens after the consumer loop terminates, not concurrently with poll.","Avoid interrupting the consumer thread for non-shutdown reasons."],"exampleFix":"// before\nList<Message> msgs = connector.getListWithoutAck(1, TimeUnit.SECONDS);\n// after\nList<Message> msgs;\ntry {\n    msgs = connector.getListWithoutAck(1, TimeUnit.SECONDS);\n} catch (CanalClientException e) {\n    if (shuttingDown) break;\n    Thread.currentThread().interrupt();\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (shuttingDown) return; // skip polling during shutdown","typeGuard":null,"tryCatchPattern":"try {\n    msgs = connector.getListWithoutAck(1, TimeUnit.SECONDS);\n} catch (CanalClientException e) {\n    if (shuttingDown && Thread.currentThread().isInterrupted()) {\n        logger.info(\"Shutting down consumer; exiting loop.\");\n        return;\n    }\n    Thread.currentThread().interrupt();\n    throw e;\n}","preventionTips":["Treat shutdown interrupts as a clean exit, not an error.","Restore the interrupt flag when propagating.","Stop the consumer loop before disconnect to avoid mid-poll interruption."],"tags":["rocketmq","canal-client","interruption","timeout","shutdown"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}