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

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants