{"record":{"id":"3079a953b43f7d14","repo":"apache/rocketmq","slug":"fetch-consume-offset-from-broker-exception","errorCode":null,"errorMessage":"Fetch consume offset from broker exception","messagePattern":"Fetch consume offset from broker exception","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"warning","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java","lineNumber":831,"sourceCode":"    private void submitConsumeRequest(ConsumeRequest consumeRequest) {\n        try {\n            consumeRequestCache.put(consumeRequest);\n        } catch (InterruptedException e) {\n            log.error(\"Submit consumeRequest error\", e);\n        }\n    }\n\n    private long fetchConsumeOffset(MessageQueue messageQueue) throws MQClientException {\n        checkServiceState();\n        long offset = this.rebalanceImpl.computePullFromWhereWithException(messageQueue);\n        return offset;\n    }\n\n    public long committed(MessageQueue messageQueue) throws MQClientException {\n        checkServiceState();\n        long offset = this.offsetStore.readOffset(messageQueue, ReadOffsetType.MEMORY_FIRST_THEN_STORE);\n        if (offset == -2) {\n            throw new MQClientException(\"Fetch consume offset from broker exception\", null);\n        }\n        return offset;\n    }\n\n    private void clearMessageQueueInCache(MessageQueue messageQueue) {\n        ProcessQueue processQueue = assignedMessageQueue.getProcessQueue(messageQueue);\n        if (processQueue != null) {\n            processQueue.clear();\n        }\n        Iterator<ConsumeRequest> iter = consumeRequestCache.iterator();\n        while (iter.hasNext()) {\n            if (iter.next().getMessageQueue().equals(messageQueue)) {\n                iter.remove();\n            }\n        }\n    }\n\n    private long nextPullOffset(MessageQueue messageQueue) throws MQClientException {","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java#L813-L849","documentation":"DefaultLitePullConsumerImpl.committed(MessageQueue) calls the offsetStore with MEMORY_FIRST_THEN_STORE; when the store lookup returns -2 (OFFSET_OVERFLOW / no readable offset — neither memory nor broker had a committed offset for the queue), it throws this MQClientException. It means the consumer group has never committed an offset for that queue anywhere.","triggerScenarios":"Calling committed(q) right after start() before any message has been pulled and auto-committed; a brand-new consumer group (CONSUME_FROM_LAST_OFFSET never materialized) on a queue that was just assigned.","commonSituations":"New group on an existing topic; checking committed offset for a queue after seek() cleared committed state; offset store wiped (new client instance with remote offsets not yet persisted).","solutions":["Poll at least once (letting auto-commit run) before querying committed()","Treat this error as 'no commit yet' and fall back to minOffset/maxOffset or consumer launch configuration (fromWhere)","Ensure autoCommit is enabled or call commitSync() before querying"],"exampleFix":"// before\nlong off = consumer.committed(queue);\n\n// after\nlong off;\ntry {\n    off = consumer.committed(queue);\n} catch (MQClientException e) {\n    off = consumer.minOffset(queue); // no commit yet: start from earliest\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    offset = consumer.committed(q);\n} catch (MQClientException e) {\n    offset = consumer.minOffset(q); // group never committed for this queue\n}","preventionTips":["Poll at least once (auto-commit) before querying committed offsets on a fresh group","Treat -2 semantics as 'no commit yet', not as a fatal error"],"tags":["rocketmq","consumer","offset","commit","new-group"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}