Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

DBSettings should be initialized in writeLock #1254

Open
chenjw13097 opened this issue Jan 22, 2019 · 3 comments
Open

DBSettings should be initialized in writeLock #1254

chenjw13097 opened this issue Jan 22, 2019 · 3 comments

Comments

@chenjw13097
Copy link

chenjw13097 commented Jan 22, 2019

org.ethereum.datasource.rocksdb.RocksDbDataSource#init(org.ethereum.datasource.DbSettings)

old code is:
public void init(DbSettings settings) {
(1)this.settings = settings;
(2)resetDbLock.writeLock().lock();
try {
logger.debug("~> RocksDbDataSource.init(): " + name);

but it should be like this:
public void init(DbSettings settings) {
resetDbLock.writeLock().lock();
try {
this.settings = settings;
logger.debug("~> RocksDbDataSource.init(): " + name);

For old code, if two thread(T1 and T2) call the method with different DbSettings, follow code may be wrong(T1(1)->T2(1)->T1(2)->T2(2)):
options.setMaxOpenFiles(settings.getMaxOpenFiles());
options.setIncreaseParallelism(settings.getMaxThreads());

@mkalinin
Copy link
Contributor

Could you please make a PR and provide a rationale behind this change in its description?

@chenjw13097
Copy link
Author

chenjw13097 commented Jan 23, 2019 via email

@chenjw13097
Copy link
Author

I did it with PR #1255.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants