Skip to content

[improve][broker] Add config fsyncEnable for RocksdbMetadataStore - #18801

Merged
codelipenghui merged 5 commits into
apache:masterfrom
coderzc:config_metadataFsyncEnabled
Dec 14, 2022
Merged

[improve][broker] Add config fsyncEnable for RocksdbMetadataStore#18801
codelipenghui merged 5 commits into
apache:masterfrom
coderzc:config_metadataFsyncEnabled

Conversation

@coderzc

@coderzc coderzc commented Dec 7, 2022

Copy link
Copy Markdown
Member

Motivation

Now, RocksdbMetadataStore enables WriteOptions.sync, which will make writing slower, I add a config metadataFsyncEnabled to allow user to disable fsync according to the need.

Modifications

Add config fsyncEnable for RocksdbMetadataStore.

Verifying this change

Such as PulsarLedgerIdGeneratorTest test execution time less

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions Bot added the doc-required Your PR changes impact docs and you will update later. label Dec 7, 2022
@coderzc
coderzc force-pushed the config_metadataFsyncEnabled branch from 5bf5bc9 to 979c37a Compare December 7, 2022 13:04
@coderzc coderzc added this to the 2.12.0 milestone Dec 7, 2022
@coderzc coderzc self-assigned this Dec 7, 2022
@coderzc coderzc added doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker ready-to-test and removed doc-required Your PR changes impact docs and you will update later. labels Dec 7, 2022
@codecov-commenter

codecov-commenter commented Dec 7, 2022

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.73%. Comparing base (68ca60c) to head (f08bf96).
⚠️ Report is 3186 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #18801      +/-   ##
============================================
- Coverage     50.05%   47.73%   -2.33%     
+ Complexity    11024    10651     -373     
============================================
  Files           703      703              
  Lines         68814    68831      +17     
  Branches       7378     7378              
============================================
- Hits          34446    32855    -1591     
- Misses        30621    32319    +1698     
+ Partials       3747     3657      -90     
Flag Coverage Δ
unittests 47.73% <ø> (-2.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 129 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jason918 Jason918 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread conf/standalone.conf Outdated
# Configuration file path for metadata store. It's supported by RocksdbMetadataStore and EtcdMetadataStore for now
metadataStoreConfigPath=

# Whether we should enable fsync for local metadata store. It's supported by RocksdbMetadataStore for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be more clear to add this: "If this flag is true, metadata writes will be slower. If this flag is false, and the machine crashes, some recent metadata writes may be lost. Note that if it is just the process that crashes (i.e., the machine does not reboot), no writes will be lost even if it is false."

public void testPut(String provider, Supplier<String> urlSupplier) throws Exception {
@Cleanup
MetadataStore store = MetadataStoreFactory.create(urlSupplier.get(), MetadataStoreConfig.builder().build());
MetadataStore store = MetadataStoreFactory.create(urlSupplier.get(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: This benchmark is not even a unit test. It's more like a perf tool.

Comment on lines +52 to +53
MetadataStoreExtended store = MetadataStoreExtended.create(urlSupplier.get(),
MetadataStoreConfig.builder().fsyncEnable(false).build());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please also help check other tests that use the fsync mode.

Comment thread conf/standalone.conf Outdated
# If this flag is true, metadata writes will be slower.
# If this flag is false, and the machine crashes, some recent metadata writes may be lost.
# Note that if it is just the process that crashes (i.e., the machine does not reboot), no writes will be lost even if it is false.
metadataFsyncEnabled=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we don't need to expose it to users?
We just want to improve the test.
Suppose we allow users to configure with false. The machine crash might lead to the metadata being corrupted.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or we can expose it until we need it. I haven't seen any issues or discussions about this part.
And batch operations might be another choice to improve the rocksdb metadata performance.

@coderzc coderzc Dec 9, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe we don't need to expose it to users? We just want to improve the test. Suppose we allow users to configure with false. The machine crash might lead to the metadata being corrupted.

@codelipenghui Rocksdb still can sync wal/memtable file by wal_bytes_per_sync and bytes_per_sync config, I think when setting wal_bytes_per_sync=1 metadata no write will be lost even if it is false.

https://github.com/facebook/rocksdb/blob/534fb06dd38234a2d6234d17366a7b0ac5272f48/include/rocksdb/options.h#L981-L1004

Whether we should automatically set wal_bytes_per_sync=1 and set WriteOptions.sync=false ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whether we should automatically set wal_bytes_per_sync=1 and set WriteOptions.sync=false ?

IIUC, WriteOptions.sync only applies fsync on WAL. So there is no need to config wal_bytes_per_sync.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or we can expose it until we need it.

+1, we should be more cautious about exposing more configs to users. I think we can keep the config of MetadataStoreConfig and remove the one in ServiceConfiguration. It would be enough to solve the unit test case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Whether we should automatically set wal_bytes_per_sync=1 and set WriteOptions.sync=false ?

IIUC, WriteOptions.sync only applies fsync on WAL. So there is no need to config wal_bytes_per_sync.

In my local test, if enable WriteOptions.sync, PulsarLedgerIdGeneratorTest.testGenerateLedgerId will timeout but only set wal_bytes_per_sync=1 it does not timeout

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Or we can expose it until we need it.

+1, we should be more cautious about exposing more configs to users. I think we can keep the config of MetadataStoreConfig and remove the one in ServiceConfiguration. It would be enough to solve the unit test case.

OK.

@coderzc coderzc changed the title [improve][broker] Add config metadataFsyncEnabled for RocksdbMetadataStore [improve][broker] Add config fsyncEnable for RocksdbMetadataStore Dec 9, 2022
@codelipenghui
codelipenghui merged commit f4e4fd5 into apache:master Dec 14, 2022
lifepuzzlefun pushed a commit to lifepuzzlefun/pulsar that referenced this pull request Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker area/test doc-not-needed Your PR changes do not impact docs ready-to-test type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants