ethereum / ethereumj

DEPRECATED! Java implementation of the Ethereum yellowpaper. For JSON-RPC and other client features check Ethereum Harmony
GNU Lesser General Public License v3.0
2.18k stars 1.09k forks source link

DBSettings should be initialized in writeLock #1254

Open chenjw13097 opened 5 years ago

chenjw13097 commented 5 years ago

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 commented 5 years ago

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

chenjw13097 commented 5 years ago

0k,I wiII do it发自我的华为手机-------- 原始邮件 --------主题:Re: [ethereum/ethereumj] DBSettings should be initialized in writeLock (#1254)发件人:Mikhail Kalinin 收件人:ethereum/ethereumj 抄送:Jiawei Chan ,Author Could you please make a PR and provide a rationale behind this change in its description?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/ethereum/ethereumj","title":"ethereum/ethereumj","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/ethereum/ethereumj"}},"updates":{"snippets":[{"icon":"PERSON","message":"@mkalinin in #1254: Could you please make a PR and provide a rationale behind this change in its description?"}],"action":{"name":"View Issue","url":"https://github.com/ethereum/ethereumj/issues/1254#issuecomment-456302287"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/ethereum/ethereumj/issues/1254#issuecomment-456302287", "url": "https://github.com/ethereum/ethereumj/issues/1254#issuecomment-456302287", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

chenjw13097 commented 5 years ago

I did it with PR #1255.