{"record":{"id":"890ad4031ee0fedc","repo":"apache/rocketmq","slug":"failed-to-get-max-offset-in-queue-or-iterate-in-qu","errorCode":null,"errorMessage":"Failed to get max offset in queue or iterate in queue","messagePattern":"Failed to get max offset in queue or iterate in queue","errorType":"exception","errorClass":"RemotingCommandException","httpStatus":null,"severity":"error","filePath":"broker/src/main/java/org/apache/rocketmq/broker/processor/NotificationProcessor.java","lineNumber":292,"sourceCode":"                    iterator = queue.iterateFrom(offset, 32);\n                    if (iterator != null) {\n                        while (iterator.hasNext()) {\n                            CqUnit cqUnit = iterator.next();\n                            if (messageFilter.isMatchedByConsumeQueue(cqUnit.getValidTagsCodeAsLong(), cqUnit.getCqExtUnit())) {\n                                return true;\n                            }\n                        }\n                        return false;\n                    }\n                } finally {\n                    if (iterator != null) {\n                        iterator.release();\n                    }\n                }\n            }\n            return restNum > 0;\n        } catch (ConsumeQueueException | RocksDBException e) {\n            throw new RemotingCommandException(\"Failed to get max offset in queue or iterate in queue\", e);\n        }\n    }\n\n    private long getPopOffset(String topic, String cid, int queueId) {\n        long offset = this.brokerController.getConsumerOffsetManager().queryOffset(cid, topic, queueId);\n        if (offset < 0) {\n            offset = this.brokerController.getMessageStore().getMinOffsetInQueue(topic, queueId);\n        }\n\n        long bufferOffset;\n        if (brokerController.getBrokerConfig().isPopConsumerKVServiceEnable()) {\n            bufferOffset = this.brokerController.getConsumerOffsetManager().queryPullOffset(cid, topic, queueId);\n        } else {\n            bufferOffset = this.brokerController.getPopMessageProcessor()\n                .getPopBufferMergeService().getLatestOffset(topic, cid, queueId);\n        }\n\n        return bufferOffset < 0L ? offset : Math.max(bufferOffset, offset);","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/broker/src/main/java/org/apache/rocketmq/broker/processor/NotificationProcessor.java#L274-L310","documentation":"NotificationProcessor (pop notification/long-polling) iterates consume queues to decide whether data is available; any ConsumeQueueException or RocksDBException from getMaxOffsetInQueue or the queue iterator is wrapped as RemotingCommandException and fails the notification request.","triggerScenarios":"Pop notification request for a topic whose consume queue or RocksDB store raises an exception during iteration — corrupt store, deleted queue mid-iteration, RocksDB backend failure.","commonSituations":"RocksDB consume-queue store (enableRocksDBStore) on failing disk; topic deleted/queues changed while notification long-polling holds an iterator; store not fully recovered.","solutions":["Read the wrapped cause in broker.log (ConsumeQueueException vs RocksDBException) to identify the backend at fault.","For RocksDB, check/repair the RocksDB directory and disk; ensure no two broker processes share it.","Avoid deleting topics with active pop consumers; drain consumers first.","Restart broker after store recovery; notifications resume when queues are readable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (RemotingCommandException e) { Throwable c = e.getCause(); if (c instanceof ConsumeQueueException || c instanceof RocksDBException) { logAndPageOnCallIfHealthy(); } else throw e; }","preventionTips":["Give RocksDB consume-queue storage dedicated, healthy disks; one process per directory.","Drain pop consumers before deleting topics to avoid iteration over dying queues."],"tags":["rocketmq","broker","pop-consumer","notification","consume-queue","rocksdb","storage"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}