qianye1001 opened a new pull request, #11536:
URL: https://github.com/apache/rocketmq/pull/11536

   ### Which Issue(s) This PR Fixes
   
   - Fixes #11535
   
   ### Brief Description
   
   Broker permission updates and role changes can advance the topic manager's 
in-memory `DataVersion` directly. The v1 `RocksDBTopicConfigManager.persist()` 
only flushes the WAL, so that version is never written to RocksDB. A graceful 
close and reopen can therefore restore an older version (for example, counter 2 
becomes 1).
   
   Persist the current version before the existing optional WAL flush. Extract 
the existing version write into `persistKvDataVersion()` and reuse it without 
advancing the counter or replacing the in-memory version. This preserves the 
counter, timestamp and state version; write failures are propagated to the 
caller.
   
   ### How Did You Test This Change?
   
   - Reproduced the regression against the unmodified code with a real RocksDB 
close/reopen test: expected counter 2, recovered counter 1.
   - Added restart coverage for all four combinations of separate/shared 
RocksDB and enabled/disabled real-time persistence. Each case verifies the full 
version, topic recovery, and that repeated `persist()` calls do not advance the 
version.
   - Added coverage for version-write failure propagation.
   - Ran `RocksDBConfigManagerTest`, `RocksDBTopicConfigManagerTest`, and 
`RocksDBTopicConfigManagerPersistenceTest`: **9 tests passed, 0 failures, 0 
errors, 0 skipped**. The 11-module Maven reactor completed successfully, 
including Checkstyle and SpotBugs checks.
   
   Validation command on macOS ARM64 with OpenJDK 21 (after initializing 
`rocketmq-apis`):
   
   ```sh
   mvn -pl broker -am \
     
-Dtest=RocksDBConfigManagerTest,RocksDBTopicConfigManagerTest,RocksDBTopicConfigManagerPersistenceTest
 \
     -Dsurefire.failIfNoSpecifiedTests=false \
     -DargLine='-Dnet.bytebuddy.experimental=true 
--add-opens=java.base/java.lang=ALL-UNNAMED 
--add-opens=java.base/java.nio=ALL-UNNAMED 
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED' \
     test
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to