{"record":{"id":"cfba0c58e6ee2cdc","repo":"apache/rocketmq","slug":"system-error","errorCode":"SYSTEM_ERROR","errorMessage":"Found unexpected result {result}","messagePattern":"Found unexpected result (.+?)","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java","lineNumber":244,"sourceCode":"                            result = this.mQClientFactory.getMQAdminImpl().searchOffset(mq, timestamp);\n                        } catch (MQClientException e) {\n                            log.warn(\"Compute consume offset from last offset exception, mq={}, exception={}\", mq, e);\n                            throw e;\n                        }\n                    }\n                } else {\n                    throw new MQClientException(ResponseCode.QUERY_NOT_FOUND, \"Failed to query offset from offset \" +\n                            \"store\");\n                }\n                break;\n            }\n\n            default:\n                break;\n        }\n\n        if (result < 0) {\n            throw new MQClientException(ResponseCode.SYSTEM_ERROR, \"Found unexpected result \" + result);\n        }\n\n        return result;\n    }\n\n    @Override\n    public int getConsumeInitMode() {\n        final ConsumeFromWhere consumeFromWhere = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer().getConsumeFromWhere();\n        if (ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET == consumeFromWhere) {\n            return ConsumeInitMode.MIN;\n        } else {\n            return ConsumeInitMode.MAX;\n        }\n    }\n\n    @Override\n    public void dispatchPullRequest(final List<PullRequest> pullRequestList, final long delay) {\n        for (PullRequest pullRequest : pullRequestList) {","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java#L226-L262","documentation":"Thrown by RebalancePushImpl.computePullFromWhere as a final invariant check: after the ConsumeFromWhere switch, the computed initial offset is still negative. Since every branch should yield >= 0 (stored offset, 0, maxOffset, or searchOffset result), a negative result means an unhandled combination — for example searchOffset returning -1 because no message existed at/after the consume timestamp. Code SYSTEM_ERROR marks it as an unexpected internal outcome rather than a config problem.","triggerScenarios":"CONSUME_FROM_TIMESTAMP with a consumeTimestamp earlier than the earliest message on the queue (searchOffset returns -1), or future edge combinations (unknown ConsumeFromWhere falling through the switch with result still -1 initialization value).","commonSituations":"consumeTimestamp set to a date before the topic's earliest retained message (expired by retention); consumeTimestamp in the far future; timestamps formatted wrongly so parsing yields epoch 0 and the queue has no matching message; newly-created queue with no messages when using TIMESTAMP mode.","solutions":["Set consumeTimestamp to a value within the topic's retention window (after the earliest message still on the broker)","If the queue may legitimately be empty or lack messages at that timestamp, prefer CONSUME_FROM_LAST_OFFSET or handle SYSTEM_ERROR at start with a retry after messages arrive","Verify the timestamp format is yyyyMMddHHmmss and represents a real point in time on that queue"],"exampleFix":"// before\nconsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);\nconsumer.setConsumeTimestamp(\"20200101000000\"); // older than retained messages -> searchOffset -1\n// after\nconsumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); // or\nconsumer.setConsumeTimestamp(\"20240601000000\"); // inside retention window","handlingStrategy":"validation","validationCode":"// before start: assert timestamp lies within the topic's retention window\nlong ts = UtilAll.parseDate(consumeTimestamp, UtilAll.YYYYMMDDHHMMSS).getTime();\nlong min = admin earliestMsgTime(topic), max = System.currentTimeMillis();\nif (ts < min) throw new IllegalArgumentException(\"consumeTimestamp older than earliest retained message; use LAST_OFFSET or a later time\");","typeGuard":null,"tryCatchPattern":"catch (MQClientException e) { if (e.getResponseCode() == ResponseCode.SYSTEM_ERROR && e.getMessage().contains(\"unexpected result\")) { consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET); rebuildAndStart(); } else throw e; }","preventionTips":["Never set consumeTimestamp before the topic's retention horizon","Default to CONSUME_FROM_LAST_OFFSET unless timestamp semantics are required","Guard against empty/new queues in TIMESTAMP mode"],"tags":["rocketmq","consumer","offset","consume-from-timestamp","invariant"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}