Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1766,19 +1766,30 @@ protected void shutdownBasicService() {
shutdownScheduledExecutorService(this.syncBrokerMemberGroupExecutorService);
shutdownScheduledExecutorService(this.brokerHeartbeatExecutorService);

// With useSingleRocksDBForAllConfigs enabled, the V1 RocksDB topic, subscription group,
// and consumer offset managers share one RocksDB instance. Persist all configs before any manager closes it.
if (this.topicConfigManager != null) {
this.topicConfigManager.persist();
this.topicConfigManager.stop();
}

if (this.subscriptionGroupManager != null) {
this.subscriptionGroupManager.persist();
this.subscriptionGroupManager.stop();
}

if (this.consumerOffsetManager != null) {
this.consumerOffsetManager.persist();
this.consumerOffsetManager.stop();
// Stop the offset manager first to drain asynchronous writes and sync the WAL.
// Log failures and continue shutting down the other managers.
if (!this.consumerOffsetManager.stop()) {
LOG.error("Failed to stop consumer offsets, continue shutting down other config managers");
}
}

if (this.topicConfigManager != null) {
this.topicConfigManager.stop();
}
if (this.subscriptionGroupManager != null) {
this.subscriptionGroupManager.stop();
}

if (this.consumerOrderInfoManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,25 @@ public void flushWAL() {
if (!isLoaded()) {
return;
}
if (this.configRocksDBStorage != null) {
this.configRocksDBStorage.flushWAL();

long now = System.currentTimeMillis();
if (now > this.lastFlushMemTableMicroSecond + this.memTableFlushInterval) {
this.configRocksDBStorage.flush(this.flushOptions);
this.lastFlushMemTableMicroSecond = now;
}
}
flushWALChecked();
} catch (Exception e) {
BROKER_LOG.error("kv flush WAL Failed.", e);
}
}

// The async offset barrier must observe flush failures to confirm persistence or safely close the database.
public void flushWALChecked() throws RocksDBException {
if (!isLoaded()) {
throw new IllegalStateException("RocksDB config storage is not loaded");
}
this.configRocksDBStorage.flushWAL();
long now = System.currentTimeMillis();
if (now > this.lastFlushMemTableMicroSecond + this.memTableFlushInterval) {
this.configRocksDBStorage.flush(this.flushOptions);
this.lastFlushMemTableMicroSecond = now;
}
}

public void put(final byte[] keyBytes, final byte[] valueBytes) throws Exception {
this.configRocksDBStorage.put(defaultCF, keyBytes, keyBytes.length, valueBytes);
}
Expand Down
Loading
Loading