9189 Commits

Author SHA1 Message Date
Jiahua Wang e348efa66b [ISSUE #10575] Fix race condition between scanResponseTable and processResponseCommand (#10576)
processResponseCommand used get+remove (non-atomic) to retrieve ResponseFuture
from responseTable. scanResponseTable used iterator.remove(). If the response
arrived between scanResponseTable's remove and processResponseCommand's get,
the response would be logged as 'not matched any request' and silently dropped.
The callback would fire with timeout instead of success, even though the broker
had successfully processed the request.

Fix: Use ConcurrentHashMap.remove(key) in both methods. This is atomic:
either processResponseCommand gets the future (and executes success callback),
or scanResponseTable gets it (and executes timeout callback), but never both
and never neither.

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-08-26 15:12:46 +08:00
rongtong 484b7b812c build: upgrade fastjson2 to 2.0.64 (#10928)
Co-authored-by: 通融 <rongtong.jrt@alibaba-inc.com>
2026-08-25 14:05:22 +08:00
lizhimins efa1be59d6 [ISSUE #10680] Release Apache RocketMQ 5.5.1 (#10961) rocketmq-all-5.5.1 2026-08-20 13:41:42 +08:00
rongtong df8194146e [ISSUE #10641] Deprecate legacy Broker DLedger mode (#10642) 2026-08-19 17:42:51 +08:00
rongtong 6a9e84f113 [ISSUE #10651] bump DLedger to 0.3.3.4 (maintenance line) (#10958)
* chore: bump DLedger to 0.3.3.4 (maintenance line)

Update the DLedger dependency from 0.3.2 to 0.3.3.4, the latest
release on the 0.3.x maintenance line published on Maven Central.
The 0.3.3.4 release is API-compatible with 0.3.2 and only carries
dependency hygiene fixes (aligning fastjson2 and excluding fastjson1
from its rocketmq-remoting transitive path).

Also update the Bazel WORKSPACE artifact coordinate to keep the two
build systems in sync.

* chore: fully remove fastjson1 from the build

DLedger 0.3.3.4 already excludes com.alibaba:fastjson from its
rocketmq-remoting dependency and its bytecode only references
fastjson2, but rocketmq still declared fastjson1 itself, so it kept
leaking onto every module compile classpath through rocketmq-common.

- drop the com.alibaba:fastjson property and dependencyManagement
  entry from the root pom
- drop the unused com.alibaba:fastjson dependency from rocketmq-common
  (no main source imports com.alibaba.fastjson.*)
- drop the fastjson1 pin from WORKSPACE and the fastjson1 dep from the
  remoting test target in remoting/BUILD.bazel
- migrate RemotingSerializableCompatTest to fastjson2: use the
  fastjson2 JSONField annotation (which is what the protocol classes
  actually carry) and round trip through RemotingSerializable instead
  of com.alibaba.fastjson.JSON

fastjson1 wire-format coverage is retained by the frozen fastjson1
payload already asserted in testCompatibilityCheckWithBitSet.

* fix(bazel): exclude rocketmq-remoting from coursier resolution

dledger 0.3.3.4 depends on rocketmq-remoting:5.5.0, which Coursier
fetches from Maven Central. That artifact transitively brings
grpc-netty-shaded:1.53.0 with a strict [1.53.0] range on grpc-core,
conflicting with the WORKSPACE-declared grpc 1.47.0 artifacts.

Since rocketmq-remoting is built from source in this repo (//remoting),
exclude it from external resolution — matching what PR #10947 already
does for the DLedger 0.4.x line.

---------

Co-authored-by: 通融 <rongtong.jrt@alibaba-inc.com>
2026-08-19 14:58:30 +08:00
ymwneu e58f9fd35a [ISSUE #10959] Fix RocksDBConsumeQueue.iterateFrom should reject offset below min offset (#10960)
startIndex < minOffset was previously accepted as long as it stayed
within [0, maxOffset), returning a non-null LargeRocksDBConsumeQueueIterator
whose next() can yield a null CqUnit once the underlying data has been
purged. Callers like ScheduleMessageService rely on iterateFrom returning
null to detect and correct an out-of-range offset (matching ConsumeQueue's
getMinLogicOffset() check); without it they NPE dereferencing the null
CqUnit instead.

Add the same startIndex >= getMinOffsetInQueue() bound used by the
file-based ConsumeQueue to both iterateFrom overloads.

Co-authored-by: maowei.ymw <maowei.ymw@alibaba-inc.com>
2026-08-19 10:56:51 +08:00
qianye cf27650066 [ISSUE #10953] Clamp shifted message count range to queue bounds (#10954) 2026-08-18 12:02:27 +08:00
dingshuangxi888 293f588571 Improve ACL 2.0 authorization context handling (#10925) 2026-08-14 09:58:51 +08:00
shown 7eee0fc366 fix(controller): detect inactive raft masters (#10885) 2026-08-13 15:46:06 +08:00
shown e47268e664 fix(controller): compare partial broker identities safely (#10886) 2026-08-13 10:06:22 +08:00
qianye 97a797543b [ISSUE #10906] Prevent duplicate MQClientInstance creation (#10907) 2026-08-12 14:02:31 +08:00
shown e3458616d2 fix(common): compare message queue ids safely (#10884) 2026-08-10 09:41:01 +08:00
lizhimins fd0c95920e [ISSUE #10827] fix(broker): spin for the lock on same-attemptId pop orderly retry to avoid empty response (#10828) 2026-08-07 18:29:26 +08:00
fuyou001 51f9fcc493 [ISSUE #10817] Upgrade SpotBugs for JDK 21 compatibility (#10818) 2026-08-06 19:22:52 +08:00
fuyou001 69f108316d Classify BrokerShutdownTest as a medium Bazel test (#10821) 2026-08-06 17:29:34 +08:00
Rui cf2b874581 [ISSUE #10813] Reduce temporary allocations in the LMQ append path (#10814)
Signed-off-by: Rui <1685901819@qq.com>
2026-08-06 17:14:37 +08:00
fuyou001 cbebac2e66 [ISSUE #10819] Correct misleading CommitLog buffer comment (#10820)
* [ISSUE #10819] Correct misleading CommitLog buffer comment

* [ISSUE #10819] Refine CommitLog comment wording
2026-08-06 16:33:59 +08:00
ymwneu 2daf0e2ca9 [ISSUE #10713] Optimize ConsumerFilterManager register CPU consumption (#10714)
- Refactor filter data index from topic-based to consumerGroup-based (SubscriptionFilterHandler)
- Add topic existence check before registering filter
- Generate BloomFilterData only when enableCalcFilterBitMap is enabled
- Fix thread safety: use ConcurrentHashMap for topicSqlFilterData
- Fix TOCTOU race conditions: replace containsKey+get with single get
- Rebuild subscriptionFilterData from filterDataByTopic in decode
- Add test for subscription shrink marking removed topics as dead
2026-08-04 12:04:19 +08:00
Quan eddb235c1b [ISSUE #10722] Lite Topic may not be cleaned up when message store timestamp is unavailable (#10723) 2026-08-03 14:04:44 +08:00
ymwneu 89166af997 [ISSUE #9654] Optimize the bufferLocal size of the TimerMessageStore (#9655) 2026-08-03 11:24:22 +08:00
lizhimins a06836dd56 [ISSUE #7703] Upgrade fastjson2 to 2.0.63 for security fixes (#10715) 2026-08-01 14:56:21 +08:00
aias00 00e45b8a6d [ISSUE #10025] Treat blank local serve address as unset (#10663) 2026-07-27 17:33:45 +08:00
yx9o 31734b150b [ISSUE #10661] Unregister all producer topics on gRPC client termination (#10662) 2026-07-27 17:33:06 +08:00
Houlong66 d8c3f9e735 [ISSUE #10572] Add dual TTL policy for tiered storage read-ahead cache (#10573) 2026-07-25 16:07:45 +08:00
Jiahua Wang b37e2bbacd [ISSUE #10639] Reuse a per-thread scratch buffer in CommitLog.checkMessageAndReturnSize (#10640)
* [ISSUE #10639] Reuse a per-thread scratch buffer in CommitLog.checkMessageAndReturnSize

* [ISSUE #10639] Reject corrupt negative totalSize before allocation in checkMessageAndReturnSize

* [ISSUE #10639] Add configurable reuse-buffer cap and unit tests for checkMessageAndReturnSize

* [ISSUE #10639] Default the check-message reuse-buffer cap to 1 MiB

---------

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-07-23 23:55:33 +08:00
Quan 577b89f2cd [ISSUE #10644] Add LMQ number gauge metric to Broker observability (#10645)
- Add GAUGE_LMQ_NUM constant in BrokerMetricsConstant
- Register ObservableLongGauge in BrokerMetricsManager reading from messageStore.getQueueStore().getLmqNum()
- Expose rocketmq_lmq_number metric for monitoring LMQ resource usage
2026-07-22 11:43:58 +08:00
Quan 4f9b187fd7 [ISSUE #10569] Support Lite Simple Consumer on server side (#10570)
- Broker: add PopLiteLongPollingService to NotificationProcessor for lite consumer notification polling
- Broker: LiteEventDispatcher notifies both PopLiteMessageProcessor and NotificationProcessor polling services
- Broker: add hasEvents(clientId) API to LiteEventDispatcher for message availability check
- Proxy: unify lite/normal pop paths into single popMessage call, route by ProxyContext.isLiteConsumer()
- Proxy: register LITE_SIMPLE_CONSUMER in ClientActivity and GrpcClientSettingsManager lifecycle
- Proxy: pass liteTopic property only for lite consumers in filter and response writer
- Proxy: remove standalone popLiteMessage from MessagingProcessor/ConsumerProcessor
- Remoting: add isLiteConsumer and clientId fields to NotificationRequestHeader
2026-07-20 10:46:46 +08:00
Quan 26cfb5f60e [ISSUE #10622] Resolve ConsumerOffsetManager dynamically in LiteEventDispatcher (#10623)
- Remove cached consumerOffsetManager field from LiteEventDispatcher
- Replace all usages with brokerController.getConsumerOffsetManager() for lazy resolution
- Allows downstream projects to swap ConsumerOffsetManager after broker init
2026-07-17 22:10:39 +08:00
Jiahua Wang 3373f284e6 [ISSUE #10613] Fix async request-reply RequestCallback firing multiple times (#10614)
- DefaultMQProducerImpl#request(Message, RequestCallback, long): drop the
  executeRequestCallback() call in the async send onSuccess so a send success
  no longer delivers a premature onSuccess(null); align with the other async
  request overloads which only set sendRequestOk here.
- RequestResponseFuture: add an AtomicBoolean executeCallbackOnlyOnce guard so
  the callback fires at most once even if the reply and timeout paths race.
- RequestFutureHolder#scanExpiredRequest: use ConcurrentHashMap.remove(key) to
  atomically claim ownership instead of iterator.remove(); also fix the log
  placeholder concatenation.
- ClientRemotingProcessor#processReplyMessage: use atomic remove(correlationId)
  and route the reply through executeRequestCallback so the single-shot guard
  covers the reply-success path too.
- Add RequestResponseFutureTest cases for success-then-timeout and concurrent
  single-callback semantics.

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-07-17 18:43:41 +08:00
imzs 45254d5e13 [ISSUE #10615] Fix missing long-polling notification under CombineConsumeQueue selective double-write (#10616) 2026-07-14 13:39:34 +08:00
Jiahua Wang 74e90f7c28 [ISSUE #10446] Support batch deletion of topics and subscription groups in broker (#10448)
* [ISSUE #10446] Support batch deletion of topics and subscription groups in broker

- Add DELETE_TOPIC_IN_BROKER_LIST and DELETE_SUBSCRIPTION_GROUP_LIST
  request codes with corresponding RequestBody types
- Implement deleteTopicList / deleteSubscriptionGroupList in
  AdminBrokerProcessor with deduplication and one-shot persist
- Add deleteTopicConfigList / deleteSubscriptionGroupConfigList in
  TopicConfigManager / SubscriptionGroupManager (single persist per batch)
- Add MQClientAPIImpl#deleteTopicInBrokerList /
  deleteSubscriptionGroupList client APIs
- Cover changes with unit tests in AdminBrokerProcessorTest

* fix: persist  config after batch delete

* fix: preserve batch delete failure response

---------

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
Co-authored-by: fuchong <yubao.fyb@alibaba-inc.com>
2026-07-13 10:07:43 +08:00
imzs c4ce550a57 [ISSUE #10604] Fix TopicConfig DataVersion not persisted in split registration (#10605) 2026-07-10 18:09:59 +08:00
aias00 0e4ccf1b66 [ISSUE #10578] Fix master election maxOffset comparator overflow
DefaultElectPolicy sorted broker candidates by subtracting maxOffset values and casting the long delta to int. Large offset gaps can overflow the comparator result and rank a lower-offset broker first. This replaces subtraction with safe comparator helpers and adds a focused overflow regression test.

Constraint: Preserve existing election order: higher epoch, higher maxOffset, lower electionPriority

Rejected: Keep subtraction comparator | unsafe for long offset deltas greater than Integer.MAX_VALUE

Confidence: high

Scope-risk: narrow

Tested: mvn -q -pl controller -DskipTests=false -Dtest=DefaultElectPolicyTest -Djacoco.skip=true test

Tested: mvn -q -pl controller -DskipTests compile -Dspotbugs.skip=true -Dcheckstyle.skip=true

Tested: mvn -q -DskipTests compile -Dspotbugs.skip=true -Dcheckstyle.skip=true

Not-tested: Full controller suite on local JDK due existing JaCoCo/Hessian module-access failures

Related: #10578
2026-07-07 19:37:13 +08:00
yx9o 2af604f3af [ISSUE #10593] Rename CLusterSendMsgRTCommand to ClusterSendMsgRTCommand (#10594)
* [ISSUE #10593] Rename CLusterSendMsgRTCommand to ClusterSendMsgRTCommand

* Update
2026-07-06 10:27:33 +08:00
Quan 8242c1e9d2 [ISSUE #10562] Optimize PopConsumerServiceTest#transferToFsStoreTest to avoid unnecessary background threads (#10563)
- Replace consumerService.start() with consumerService.getPopConsumerStore().start()
- Replace consumerService.shutdown() with consumerService.getPopConsumerStore().shutdown()
- Avoid starting revive/cache background threads that are not needed for transferToFsStore verification
- Reduces test execution time from ~60s to ~1.3s
2026-07-01 14:03:54 +08:00
Quan 1730dbc040 [ISSUE #10560] Remove enableLiteEventMode config switch (#10561)
* [ISSUE #10560] Remove enableLiteEventMode config switch

- Remove enableLiteEventMode field, getter and setter from BrokerConfig
- Remove 5 early-return guard checks in LiteEventDispatcher
- Remove dead condition in PopLiteMessageProcessor.popLiteTopic
- Simplify getEventIterator to always use event-set path
- Delete unused LiteSubscriptionIterator inner class
- Remove disabled-mode test cases and stale Javadoc references

* chore: retrigger CI
2026-07-01 13:50:53 +08:00
SSpirits 88709c56aa [ISSUE #10543] resolve data race in ServiceThread wakeup mechanism (#10544) 2026-06-30 10:26:23 +08:00
Surya Kant f4c0c4d3a4 docs: format README for consistent Markdown style (#10551)
Normalize horizontal rules, blank lines around headings and code
blocks, list markers, nested list indentation, and trailing whitespace
without changing content.
2026-06-29 19:16:54 +08:00
Quan 49102a9985 [ISSUE #10549] Fix lite topic reset offset: memory leak, FIFO block bypass, and offset-0 reset failure (#10550)
* [ISSUE #10549] Fix lite topic reset offset: memory leak, FIFO block bypass, and offset-0 reset failure

- Fix memory leak in removeResetOffset: clean up empty inner map entries from resetOffsetTable
- Add eraseResetOffset for precise cleanup on lite topic removal
- Skip FIFO block check in isFifoBlocked when server-side reset offset is pending
- Fix ResetOffsetByTimeCommand: change resetOffset > 0 to >= 0 to allow resetting to offset 0
- Add unit tests for eraseResetOffset and isFifoBlocked reset bypass

* chore: empty commit to trigger CI pipeline
2026-06-29 15:34:00 +08:00
Quan 10d498c68a [ISSUE-10546] Add default implementation for rejectRequest() in NettyRequestProcessor (#10547) 2026-06-25 10:22:35 +08:00
chenxu80 2e6632ff40 [ISSUE #10417] Fix stale minOffset after consumeQueue truncation (#10418) 2026-06-23 17:10:16 +08:00
rongtong b5bc1ff5d6 Fix flaky HATest semi-sync replication (#10495) 2026-06-21 09:37:25 +08:00
LeiXiaoGao c4ae761f09 docs: fix broker container reference and producer typos (#10449) 2026-06-20 10:54:59 +08:00
echooymxq bfbbb2a955 [#10421] Fix Timer message rocksdb use wrong cache key. (#10422) 2026-06-20 10:44:49 +08:00
yin_bo_ e213756971 [ISSUE #10419] Fix NPE when class filter route data is missing (#10420)
* [ISSUE #10419] Fix NPE when class filter route data is missing

* [ISSUE #10419] Add class filter route fallback tests
2026-06-20 10:27:55 +08:00
Jiahua Wang c270c60f85 [ISSUE #10441] Reduce per-RPC allocation in metrics by caching static AttributeKey instances (#10443)
Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-06-19 09:41:57 +08:00
Jiahua Wang 5977e9cb1f [ISSUE #10522] Reduce Remoting header encoding allocation via FastCodesHeader/RocketMQSerializable optimizations
- Add writeDecimalLong/writeDecimalInt to RocketMQSerializable for direct primitive decimal encoding

- Add writeLong/writeInt helpers to FastCodesHeader

- Optimize writeIfNotNull to route Long/Integer through primitive writers

- Cache single-byte ASCII strings in RocketMQSerializable.readStr

- Right-size HashMap initial capacity in mapDeserialize (128 -> 24)

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-06-19 09:41:19 +08:00
lizhimins f941dced39 [ISSUE #10521] Use madvise(MADV_RANDOM) to disable kernel read-ahead during correctMinOffset binary search (#10523) 2026-06-17 19:43:16 +08:00
Jiahua Wang 971d568433 [ISSUE #10515] Fix TransactionMetricsFlushService busy spin bug (#10517)
Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-06-17 15:01:48 +08:00
Jiahua Wang 9b91157f30 [ISSUE #10486] Add getMessageType(Map) overload to eliminate redundant properties decode (#10487)
BrokerMetricsManager.getMessageType(SendMessageRequestHeader) is called
once per send to classify the message. It internally decodes the
properties String into a HashMap, but the typical caller
(SendMessageProcessor) has already decoded the same String moments
before. The result is a redundant decode allocation per send (one
HashMap + ~14 String substrings + one Node[]).

This commit adds a public overload getMessageType(Map<String, String>)
that lets callers pass an already-decoded Map and reuse it. The
existing SendMessageRequestHeader overload now delegates to the new
overload; behavior is unchanged for callers that don't have a decoded
Map. Downstream callers (e.g. SendMessageProcessor) can switch to the
new overload in a separate broker-layer commit.

Co-authored-by: wangjiahua.wjh <wangjiahua.wjh@alibaba-inc.com>
2026-06-17 14:11:01 +08:00