Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #7064] [RIP-66] Support KV(RocksDB) Storage #7065

Closed
wants to merge 43 commits into from

Conversation

fujian-zfj
Copy link
Contributor

Which Issue(s) This PR Fixes

Fixes #7064

Brief Description

This proposal mainly optimizes and solves the existing perfermance problems in the million-topic scenario from two levels:

  1. Metadata like topic, subscription, consumerOffset implement kv storage
  2. ConsumeQueue index file implements kv storage

@@ -27,7 +29,7 @@

import static org.apache.rocketmq.common.TopicAttributes.TOPIC_MESSAGE_TYPE_ATTRIBUTE;

public class TopicConfig {
public class TopicConfig implements Serializable {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议这么改

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除

@@ -104,5 +104,10 @@
<groupId>io.github.aliyunmq</groupId>
<artifactId>rocketmq-logback-classic</artifactId>
</dependency>
<!-- rocksdb -->
<dependency>
<groupId>io.github.aliyunmq</groupId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rely on a commercial version? How to ensure the stability of this version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still open source, but we need a new compactionFilter for ConsumeQueue. If you're interested, see how flink uses rocksdb.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujian-zfj Your purpose of building custom rocksdb is to define a compaction filter. What a custom compaction filter expects is native function. Will this way be better alternative:

  1. Use official rocksdb-java jar;
  2. Build a shared library(dynamically linked with rocksdb shared library) for expected custom compaction filters;
  3. When configuring RocksDB, pass the native function to it, because it does not matter which shared library the compaction filter stays in;
    As a matter of fact, this is how the native programming languages use rocksdb in case of dynamic link.

<groupId>io.github.aliyunmq</groupId>
<artifactId>rocketmq-rocksdb</artifactId>
<version>${rocksdb.version}</version>
</dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this feature compatible with other platforms (Windows and macOS)? If not, should we set it as optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support Windows, MacOS and Linux

@codecov-commenter
Copy link

codecov-commenter commented Jul 25, 2023

Codecov Report

Merging #7065 (ea03a1e) into develop (90c5382) will decrease coverage by 0.08%.
Report is 4 commits behind head on develop.
The diff coverage is 40.57%.

@@              Coverage Diff              @@
##             develop    #7065      +/-   ##
=============================================
- Coverage      42.72%   42.64%   -0.08%     
- Complexity      9282     9480     +198     
=============================================
  Files           1138     1157      +19     
  Lines          81146    83192    +2046     
  Branches       10619    10850     +231     
=============================================
+ Hits           34672    35481     +809     
- Misses         42137    43297    +1160     
- Partials        4337     4414      +77     
Files Changed Coverage Δ
...he/rocketmq/broker/controller/ReplicasManager.java 44.69% <ø> (-1.59%) ⬇️
...mq/broker/offset/RocksDBConsumerOffsetManager.java 0.00% <0.00%> (ø)
...ocketmq/broker/processor/SendMessageProcessor.java 36.29% <ø> (ø)
.../subscription/RocksDBLmqConsumerOffsetManager.java 0.00% <0.00%> (ø)
...bscription/RocksDBLmqSubscriptionGroupManager.java 0.00% <0.00%> (ø)
.../subscription/RocksDBSubscriptionGroupManager.java 0.00% <0.00%> (ø)
...tmq/broker/topic/RocksDBLmqTopicConfigManager.java 0.00% <0.00%> (ø)
...cketmq/broker/topic/RocksDBTopicConfigManager.java 0.00% <0.00%> (ø)
.../consumer/store/RocksDBOffsetSerializeWrapper.java 0.00% <0.00%> (ø)
...java/org/apache/rocketmq/common/ConfigManager.java 56.41% <0.00%> (-3.05%) ⬇️
... and 41 more

... and 26 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

this.flushOptions.setAllowWriteStall(false);

this.writeBatch = new WriteBatch();
this.bufferDRList = new ArrayList(BATCH_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw use of parameterized class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@lizhanhui
Copy link
Contributor

It's a huge pull request, containing massive changes to core parts of this project with more than 6000 lines of change. Thus, it's challenging to have a quality review. Normally, developers would break it into a series of small and verifiable ones to keep community participation.

@@ -746,7 +760,12 @@ public boolean initializeMetadata() {
public boolean initializeMessageStore() {
boolean result = true;
try {
DefaultMessageStore defaultMessageStore = new DefaultMessageStore(this.messageStoreConfig, this.brokerStatsManager, this.messageArrivingListener, this.brokerConfig, topicConfigManager.getTopicConfigTable());
DefaultMessageStore defaultMessageStore;
if (isEnableRocksDBStore()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will SPI be a better choice than if...else?

@@ -225,7 +225,7 @@ public void shutdown() {

public synchronized void changeBrokerRole(final Long newMasterBrokerId, final String newMasterAddress,
final Integer newMasterEpoch,
final Integer syncStateSetEpoch, final Set<Long> syncStateSet) {
final Integer syncStateSetEpoch, final Set<Long> syncStateSet) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception is too general...Create one within the project exception hierarchy

@@ -235,7 +235,7 @@ public synchronized void changeBrokerRole(final Long newMasterBrokerId, final St
}
}

public void changeToMaster(final int newMasterEpoch, final int syncStateSetEpoch, final Set<Long> syncStateSet) {
public void changeToMaster(final int newMasterEpoch, final int syncStateSetEpoch, final Set<Long> syncStateSet) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Copy link
Contributor

@lizhanhui lizhanhui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please break this huge PR into smaller ones

@fujian-zfj fujian-zfj closed this Jul 28, 2023
@fujian-zfj fujian-zfj reopened this Jul 28, 2023
@fujian-zfj
Copy link
Contributor Author

Please break this huge PR into smaller ones

OK, I will split it into two PRS, metadata and consumeQueue

@RongtongJin RongtongJin closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RIP-66] Support KV(Rocksdb) Storage
7 participants