Commit Graph

8894 Commits

Author SHA1 Message Date
guyinyou dbd935fe22 [ISSUE #9709] Add enableRunningFlagsInFlush configuration switch for CommitLog
- Add configuration to control runningFlags usage in CommitLog (default: false)
- Update CommitLog and AllocateMappedFileService to respect the configuration
- Users can enable runningFlags validation as needed

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-19 11:16:18 +08:00
guyinyou 0e72809335 [ISSUE #9705] Improve persist() method reliability to prevent broker startup failure after power outages (#9706)
* fix: prevent broker startup failure after power outage

- Add atomic file backup mechanism in persist() methods
- Delete corrupted config files during startup to avoid bak file pollution
- Add directory sync to ensure file operations visibility

Fixes: TimerMetrics#persist, TransactionMetrics#persist, ConfigManager#persist

* remove "Shutdown" implements

* empty commit

* add SuppressWarnings

* fix ut

* fix ut

* pass rocksdb ut when isMac()

* pass rocksdb ut when isMac()

* pass rocksdb ut when isMac()

* pass rocksdb ut when isMac()

* pass RocksdbGroupConfigTransferTest ut when isWindows()

* pass Rocksdb ut when isMac()

---------

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-18 22:32:19 +08:00
rongtong 73e8fdbdb8 [ISSUE #9699] Optimize shutdown process and resource management (#9700)
* Optimize shutdown process and resource management

- Improve BrokerController shutdown flow for graceful shutdown
- Optimize BrokerStartup startup and shutdown logic
- Enhance ClientHousekeepingService resource cleanup
- Improve shutdown handling for various processors
- Optimize resource management in storage layer components
- Enhance lifecycle management for statistics manager
- Improve shutdown flow for timer components

* Fix this.popMessageProcessor.getPopLongPollingService() not shutdown

* Fix test shutdown state transition issue

- Add proper null checks and exception handling in test cleanup
- Prevent IllegalStateException during test teardown
- Ensure graceful test cleanup without state conflicts

* Fix DefaultMessageStoreCleanFilesTest can not pass

* Fix CombineConsumeQueueStoreTest can not pass

* Polish the code

* Polish the code

* Ignore flaky test first
2025-09-17 19:21:49 +08:00
guyinyou 93f60db5f6 [ISSUE #9713] Improve data consistency in DefaultMappedFile flush method
- Move FLUSHED_POSITION_UPDATER.set() inside try block
- Prevent false positive flush success when actual flush operation fails
- Ensure data consistency and prevent potential data loss on system crash

Previously, flushed position was updated even when flush operation failed,
which could lead to data loss as the system would incorrectly assume
data was persisted to disk when it was still in memory.

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-16 21:34:50 +08:00
guyinyou 1d9b02ca46 [ISSUE #9707] Integrate RunningFlags with MappedFile system for better error handling and state management (#9708)
* Add RunningFlags support to MappedFileQueue

- Integrate RunningFlags throughout MappedFileQueue hierarchy
- Add writeable state checking and error handling in DefaultMappedFile
- Update MappedFile interface and constructors to support RunningFlags
- Implement proper error state management during flush operations

* fix ut

* fix ut

---------

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-16 16:58:42 +08:00
qianye d0e31a2b34 [ISSUE #9703] Remove pull offset and reset offset when deleting topic (#9704) 2025-09-16 10:49:34 +08:00
guyinyou 02f413d410 [ISSUE #9701] Synchronize metrics shutdown to prevent JVM crashes during broker shutdown (#9702)
* fix: synchronize metrics shutdown to prevent JVM crash

- Change async shutdown to sync blocking wait in BrokerMetricsManager
- Ensure proper shutdown order to avoid race conditions
- Prevent accessing dependencies after they are shutdown
- Use join() with timeout to wait for CompletableFuture completion
- Apply fix to all metrics exporter types (OTLP_GRPC, PROM, LOG)

* fix codestyle

---------

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-15 17:40:18 +08:00
guyinyou 4ae02942e5 [ISSUE #9693] Add writeWithoutMmap configuration to prevent JVM crash when device becomes read-only (#9694)
* add "writeWithoutMmap"

* fix npe

---------

Co-authored-by: guyinyou <guyinyou.gyy@alibaba-inc.com>
2025-09-14 14:43:06 +08:00
lizhimins edaffe6906 [ISSUE #9695] Not use pull offset when use pop orderly consume (#9696) 2025-09-12 17:26:16 +08:00
rongtong 7967edfc5e [ISSUE #9677] Resolve metrics static variable conflicts in BrokerContainer mode (#9678)
* Cherry-pick partial changes from 67db1757df - BrokerMetricsManager refactoring

- Excluded DefaultMappedFile, METRICS_REFACTORING_GUIDE.md, TimerMetrics, and RocksDB files per requirements
- Successfully applied changes to most broker and store modules
- Compilation errors in TimerMessageStore.java will be fixed in next commit

* fix: Resolve metrics static variable conflicts in BrokerContainer mode

Convert static metrics variables to instance-level to fix resource leaks and
data conflicts in BrokerContainer scenarios with multiple broker instances.

## Problem Statement
In BrokerContainer mode, multiple broker instances share static metrics variables
from BrokerMetricsManager and DefaultStoreMetricsManager, causing:
- Metrics data conflicts between different broker instances
- Resource leaks during frequent addBroker/removeBroker operations
- Incorrect metrics aggregation across multiple brokers

## Solution
- Convert static metrics variables to instance-level variables
- Add proper getter methods for external access
- Ensure each broker instance maintains isolated metrics
- Apply instanceof checks for type safety in TimerMessageStore

## Files Modified
- broker/src/main/java/org/apache/rocketmq/broker/metrics/BrokerMetricsManager.java
- store/src/main/java/org/apache/rocketmq/store/timer/TimerMessageStore.java
- METRICS_REFACTORING_GUIDE.md (documentation)

## Key Benefits
 Eliminates metrics conflicts between broker instances
 Prevents resource leaks in dynamic broker scenarios
 Maintains proper metrics isolation per broker
 Supports BrokerContainer mode with multiple brokers
 Backward compatible with existing functionality

Resolves metrics static variable issues in multi-broker container environments.

* Delete useless file

* Fix test can not pass

* Fix test can not pass
2025-09-11 16:29:20 +08:00
rongtong c3c6832f35 [ISSUE #9680] Improve RocksDB compaction filter factory resource management (#9681)
* feat: improve rocksdb compaction filter factory resource management

- Refactor ConsumeQueueCompactionFilterFactory to use LongSupplier instead of MessageStore
- Add proper resource cleanup in ConsumeQueueRocksDBStorage.preShutdown()
- Update RocksDBOptionsFactory to accept external compaction filter factory
- Optimize write buffer size for CQ rocksdb performance

This change improves resource management and reduces memory leaks by:
1. Decoupling compaction filter from MessageStore reference
2. Ensuring proper cleanup of native resources
3. Making compaction filter factory lifecycle manageable

* Polish the code

* Fix consumeQueueCompactionFilterFactory not use
2025-09-11 14:15:02 +08:00
mxsm 809bfe6cb8 [ISSUE #9682] Increase initial delay for scanning inactive brokers to 5000 milliseconds (#9683) 2025-09-10 14:04:53 +08:00
ccwss ce5a77db41 [ISSUE 9547] Fix sync group if attributes isn't null 2025-09-10 09:51:30 +08:00
rongtong bb45b8f5f7 [ISSUE #9634] Improve BrokerContainer extensibility and module structure (#9635)
* Initially optimize the broker container structure

* refactor: Improve BrokerContainer extensibility and logging

This commit enhances the BrokerContainer module to improve code structure
and logging capabilities:

Key improvements:
- Polish the code structure to make BrokerContainer more extensible
- Improve container logging configuration and management
- Enhance BrokerBootHook for better hook management
- Update BrokerContainer and BrokerContainerProcessor for improved functionality
- Remove unused BrokerLogbackConfigurator to reduce complexity
- Update BrokerStartup and BrokerController for better container integration

Modified files:
- broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
- broker/src/main/java/org/apache/rocketmq/broker/BrokerStartup.java
- container/src/main/java/org/apache/rocketmq/container/BrokerBootHook.java
- container/src/main/java/org/apache/rocketmq/container/BrokerContainer.java
- container/src/main/java/org/apache/rocketmq/container/BrokerContainerProcessor.java
- container/src/main/java/org/apache/rocketmq/container/BrokerContainerStartup.java
- container/src/main/java/org/apache/rocketmq/container/logback/BrokerLogbackConfigurator.java (removed)

This refactoring improves the overall maintainability and extensibility
of the container module while maintaining backward compatibility.

* test: Add unit tests for BrokerContainer extensibility improvements

This commit adds comprehensive unit tests for the BrokerContainer
extensibility improvements introduced in this branch:

Key test coverage:
- BrokerBootHook system extensibility and proper hook execution
- Container configuration accessibility and management
- Container initialization and lifecycle management
- BrokerContainerProcessor integration
- Startup and shutdown sequence robustness
- Extension points and customization capabilities

These tests ensure that the improved BrokerContainer architecture
maintains backward compatibility while providing enhanced extensibility
for future development and customization.

* Fix testBrokerGracefulShutdown can not pass

* Fix BrokerContainerExtensibilityTest can not pass

* fix(container): add missing auth module dependency

- Add //auth dependency to container target in BUILD.bazel
- Add //auth dependency to tests target in BUILD.bazel
- Fixes compilation errors for AuthConfig class usage
- Resolves Bazel build failures in container module

Fixes: symbol not found org.apache.rocketmq.auth.config.AuthConfig
2025-09-09 16:12:43 +08:00
rongtong 86e8ed630b [ISSUE #9666] Add accelerated startup recovery feature for RocksDB store with SYNC_FLUSH (#9667)
* feat: Add accelerated startup recovery feature

Add accelerated startup recovery functionality when using RocksDB store with SYNC_FLUSH configuration:

- Add enableAcceleratedRecovery configuration option in MessageStoreConfig
- Implement accelerated recovery logic in CommitLog for both normal and abnormal recovery
- Add protective fallback mechanism to handle edge cases
- Improve isMappedFileMatchedRecover method for better robustness
- Add comprehensive unit tests for the accelerated recovery feature

This feature significantly reduces startup time when recovering from RocksDB-based storage
with synchronous flushing enabled, while maintaining data consistency and safety.

* Fix the issue of accelerated startup failure

* refactor: Remove problematic unit test

Remove AcceleratedRecoveryTest.java as the test implementation was not appropriate for the accelerated startup recovery feature.

* Delete useless code
2025-09-09 14:11:24 +08:00
yx9o 40622ce1dd [ISSUE #9764] Fix bazel-compile (ubuntu-latest) error (#9675) 2025-09-09 10:09:03 +08:00
rongtong 32d68e7856 [ISSUE #9581] Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios (#9579)
* Optimize the resource bloat of pollingMap and topicCidMap in LMQ scenarios

* Fix PopLongPollingServiceTest some tests can not pass
2025-09-08 13:49:48 +08:00
yx9o 2f89371f87 [ISSUE #9620] placeholder replacement string concatenation (#9621) 2025-09-05 09:03:40 +08:00
yx9o 632dc324ff [ISSUE #9650] Unified FAQ related URLs (#9651)
* [ISSUE #9650] Unified FAQ related URLs

* Update

* Update
2025-09-04 17:24:57 +08:00
cvictory 1c23a8094a [ISSUE #9663] Adopt Maven's revision mechanism (requires Maven >= 3.5.0) (#9665)
Co-authored-by: cvictory <shengli.caosl@alibaba-inc.com>
2025-09-04 09:51:02 +08:00
Liu Shengzhong 365b297b0c [ISSUE #7837] Fix start() and shutdown() of DefaultMessagingProcessor (#7838)
* Fix start and shutdown process of DefaultMessagingProcessor

* minimal changes
2025-09-03 16:37:57 +08:00
Duxuwei 74ab3ae112 [ISSUE #9648] Fix getOffsetInQueueByTime missing boundaryType in tieredMessageStore (#9649)
* [ISSUE #9648] Fix getOffsetInQueueByTime missing in tieredMessageStore

* Update TieredMessageStoreTest.java

* Delete inappropriate UT

* Remove unused import
2025-09-02 19:49:40 +08:00
Duxuwei 29546558d2 [ISSUE #9652] Enhance test for MQClientInstance (#9653) 2025-09-01 17:55:23 +08:00
Hongxu Xu 7ab7ddd6d2 [ISSUE #9609] Fix bazel CI and reduce dependencies (#9610) 2025-08-22 16:35:39 +08:00
lizhimins e6a587a82a [ISSUE #9626] Prevent premature offset commit before consumer record flush (#9627)
* [ISSUE #9626] Prevent premature offset commit before consumer record flush
2025-08-22 14:43:50 +08:00
hqbfz f40a69f9f1 fix: remove wrong logic in the callback for sending messages in rpc (#9608)
Co-authored-by: hqbfzwang <hqbfzwang@tencent.com>
2025-08-12 18:51:35 +08:00
lizhimins c05dcdc155 [ISSUE #9611] Should exec callback in the Pop based on rocksdb impl (#9612) 2025-08-12 16:58:22 +08:00
qianye 9e2445ee9a [ISSUE #9589] Optimize broker metrics initialization (#9598) 2025-08-12 14:23:00 +08:00
Xiao Yang 6d4fb83577 [ISSUE #9605] Fixed a potential resource leak (#9606) 2025-08-09 15:45:35 +08:00
ccwss 960972237f [ISSUE #9596] Optimize log in invokeSync when addr is null (#9597) 2025-08-06 15:33:50 +08:00
qianye f798f96df1 [ISSUE #9254] Optimize innerConsumeQueueStoreList order in CombineConsumeQueueStore 2025-08-06 10:03:31 +08:00
co63oc 2791833b91 Fix typos (#9560) 2025-07-28 20:13:25 +08:00
Xiao Yang 100f467f6c [ISSUE #9572] Unnecessary code comment cleanup (#9573) 2025-07-28 10:05:54 +08:00
qianye e20d56b9bd [ISSUE #9254] Refactor notifyMessageArriveInBatch in RocksDBConsumeQueueStore to adapt to CombineConsumeQueueStore (#9566) 2025-07-23 16:11:56 +08:00
Jixiang Jin 438077e7ad Limit group max length to 120. (#9563)
* limit group length to 120 for max length for pop retry topic is 255.
* Add unit test for validating group.
* Fix unit test for validating gRPC group, limit length to 120
2025-07-22 17:51:50 +08:00
Xiao Yang 40e3aa938f [ISSUE #9553] Improve performance by avoiding repeated get(key) (#9554)
* [ISSUE #9553] Improve performance by avoiding repeated get(key)

* Update
2025-07-20 10:05:52 +08:00
ccwss 1f24f09992 [ISSUE #9555 ]fix the npe in the hashCode method when subscriptionDataSet is null 2025-07-19 17:59:24 +08:00
rongtong 9c1ca2a21f Remove the meaningless brokerVersion (#9533) 2025-07-15 11:40:53 +08:00
ccwss e4b731cf43 [ISSUE #9539] Fix compare policy entry logic in ACL 2.0 (#9540) 2025-07-14 15:44:00 +08:00
lizhimins d8fa28c472 [ISSUE #9544] Must correct file size when init the file segment (#9545) 2025-07-14 14:08:35 +08:00
qianye 76cee72cc5 [ISSUE #9537] MQClientAPIFactory Implement NameServerUpdateCallback interface (#9538) 2025-07-11 14:31:15 +08:00
qianye 8639dcc4da [ISSUE #9254] Optimize the logs of the message store (#9528) 2025-07-11 14:26:42 +08:00
rongtong 2accb97977 [ISSUE #9520] Remove unnecessary topicConfig data version change when enable split registration (#9521) 2025-07-10 13:55:19 +08:00
hqbfz 1a747d1472 opti: opti thread count in adaptiveBackOffSpinLock (#9530)
Co-authored-by: hqbfzwang <hqbfzwang@tencent.com>
2025-07-10 10:19:10 +08:00
hqbfz 9337904cdf [ISSUE #9309]opti:Avoid the generation of dirty data in #assignResetOffset (#9310)
* feat: support clients to reset lmq consumption offset

* fix

* fix

* fix

* fix: clean pull offset in #removeOffset

* fix: clean pull offset in #removeOffset

* rerun test

---------

Co-authored-by: hqbfzwang <hqbfzwang@tencent.com>
2025-07-09 09:56:26 +08:00
qianye ecd78d9958 fix (#9526) Fix combineCQ extra search commitLog files for recovery
Fix combineCQ extra search commitLog files for recovery
2025-07-08 14:10:13 +08:00
qianye 3d94585693 fix (#9516) Return origin handle to consumer when changeInvisibleDuration encounters flow limit
Return origin handle to consumer when changeInvisibleDuration encounters flow limit
2025-07-08 10:17:37 +08:00
Xiao Yang 0f6b427d4a [ISSUE #9501] correcting mismatched comments (#9502)
* [ISSUE #9501] correcting mismatched comments

* Update
2025-07-04 10:02:27 +08:00
fcq 0a32a54105 Fix CONTRIBUTING.md spelling mistake (#9511) 2025-07-04 09:48:53 +08:00
EnableAsync c3c4101b4c refactor(proxy): Make TLS certificate watch interval configurable (#9513)
refactor(proxy): Make TLS certificate watch interval configurable
2025-07-02 09:59:51 +08:00