<p>Ok, I found a solution. Adding </p>

<pre><code>set_lk_max_lockers 400000
</code></pre>

<p>Did the trick.  </p>

<p><a href="https://docs.oracle.com/cd/E17276_01/html/api_reference/C/set_lk_max_lockers_parameter.html" rel="nofollow noreferrer">https://docs.oracle.com/cd/E17276_01/html/api_reference/C/set_lk_max_lockers_parameter.html</a></p>

<p>I tested and was able to auto-create and load 932 wallets, until I hit an out of memory error:</p>

<pre><code>Logging region out of memory; you may need to increase its size
DB_TXN-&gt;abort: log undo failed for LSN: 227 171878: Not enough space
PANIC: Not enough space
PANIC: DB_RUNRECOVERY: Fatal error, run database recovery
PANIC: fatal region error detected; run recovery
</code></pre>

<p>Setting: </p>

<pre><code>set_lg_regionmax 1048576
</code></pre>

<p>Resolves the above <code>Logging region out of memory; you may need to increase its size</code> issue.</p>

CC BY-SA 4.0
2018-12-21T05:29:27.320Z
can you please tell me where you kept this `set_lk_max_lockers 400000` ?? in db.cpp ? https://github.com/bitcoin/bitcoin/blob/master/src/wallet/db.cpp#L166
user1140237
CC BY-SA 4.0
2018-12-21T12:34:36.893Z
I've created DB_CONFIG file in data directory of core daemon and given two values as mentioned but still its i am getting same issue daemon crashed after 250+ wallets can you please guide me or share how to use above things?
user1140237
CC BY-SA 4.0
2018-12-23T06:04:56.047Z
Yes DB_CONFIG  is in the datadir as far as I can recall. I think  I also minimized the `-keypool=20` (or 10). In any case  I dumped this idea and I don't recommend going that path.
kobik
CC BY-SA 4.0
2018-12-23T06:05:59.443Z
So is there any otherway..?
user1140237
CC BY-SA 4.0
2018-12-23T06:07:02.630Z
I mean if found anything ...please suggest .. thanks..
user1140237
CC BY-SA 4.0
2018-12-23T06:18:18.977Z
The other way is to manually manage the private keys/wallets. It's much harder but you are not limited in any way.
kobik
CC BY-SA 3.0
2018-02-13T15:49:37.597Z
2018-02-13T16:21:39.107Z
2018-02-13T16:21:39.107Z
kobik
<p>Bitcoin Core 0.15.1 has <a href="https://bitcoin.org/en/release/v0.15.0#multi-wallet-support" rel="nofollow noreferrer">Multi wallets support</a>:</p>

<p>In the <code>bitcoin.conf</code> we can add multiple entries of:</p>

<pre><code>wallet=wallet-1.dat
wallet=wallet-2.dat
wallet=wallet-3.dat
wallet=wallet-4.dat
...
wallet=wallet-350.dat
</code></pre>

<p>When Bitcoin Core starts, if the wallet file does not exists it will create it. which is great for our needs.</p>

<p>However, it <strong>always</strong> crashes on the 333 wallet. with <code>db.log</code> error:</p>

<pre><code>Lock table is out of available locker entries
</code></pre>

<p>And <code>debug.log</code>:</p>

<pre><code>2018-02-13 14:47:05 init message: Loading wallet...
2018-02-13 14:47:05 nFileVersion = 160000
2018-02-13 14:47:05 Keys: 21 plaintext, 0 encrypted, 21 w/ metadata, 21 total
2018-02-13 14:47:05  wallet                   36ms
2018-02-13 14:47:05 setKeyPool.size() = 20
2018-02-13 14:47:05 mapWallet.size() = 0
2018-02-13 14:47:05 mapAddressBook.size() = 0
2018-02-13 14:47:05 init message: Loading wallet...
2018-02-13 14:47:05 

************************
EXCEPTION: St13runtime_error       
CDB: Error 12, can't open database wallet-333.dat       
D:\BitcoinCore\bitcoin-0.16.0\bin\bitcoin-qt.exe in Runaway exception     
</code></pre>

<p>I also tried to minimize the <code>-keypool=20</code> so that the wallets size will be much smaller in size, and the process of loading them is much faster.</p>

<p>I was suggested that this error is because each wallet.dat file is opened in the same BDB environment. The entire environment has a limited number of database locks, and it seems like 333 wallets hits that number of database locks.</p>

<p>The solution (which did not work) is to create a file named <code>DB_CONFIG</code> in the data dir, and put the following lines in that file:</p>

<pre><code>set_lk_max_locks 400000
set_lk_max_objects 400000
</code></pre>

<p>By default it is 40000 and now 400000 (ten times more locks available)</p>

<p>But this gave the same results.</p>

<p>I tried also:</p>

<pre><code>set_lg_dir database
</code></pre>

<p>With no luck. </p>

<p>I verified this on two different Windows 10 machines with 0.15.1 and 0.16.0. Same result. It always crashes when loading the 333 wallet.</p>

<p>Anyone have a solution to this?</p>

<p>I have put the list of wallets if anyone care to reproduce: <a href="https://pastebin.com/8wHD1tL3" rel="nofollow noreferrer">https://pastebin.com/8wHD1tL3</a></p>

CC BY-SA 3.0
2018-02-13T15:40:27.257Z
For starters, you should file a bug report.  Even if there is a limit, the client should fail gracefully when the limit is reached, instead of crashing.  https://github.com/bitcoin/bitcoin/issues
Nate Eldredge
<bitcoin-core><bitcoind><wallet.dat>
Bitcoin Core Multi-wallet limit to 333 wallets
kobik
# Bitcoin Core Multi-wallet limit to 333 wallets

(Asked by: username_0 on 2018-02-13)

Bitcoin Core 0.15.1 has Multi wallets support:
In the bitcoin.conf we can add multiple entries of:
wallet=wallet-1.dat
wallet=wallet-2.dat
wallet=wallet-3.dat
wallet=wallet-4.dat
...
wallet=wallet-350.dat

When Bitcoin Core starts, if the wallet file does not exists it will create it. which is great for our needs.
However, it always crashes on the 333 wallet. with db.log error:
Lock table is out of available locker entries

And debug.log:
2018-02-13 14:47:05 init message: Loading wallet...
2018-02-13 14:47:05 nFileVersion = 160000
2018-02-13 14:47:05 Keys: 21 plaintext, 0 encrypted, 21 w/ metadata, 21 total
2018-02-13 14:47:05  wallet                   36ms
2018-02-13 14:47:05 setKeyPool.size() = 20
2018-02-13 14:47:05 mapWallet.size() = 0
2018-02-13 14:47:05 mapAddressBook.size() = 0
2018-02-13 14:47:05 init message: Loading wallet...
2018-02-13 14:47:05 

************************
EXCEPTION: St13runtime_error       
CDB: Error 12, can't open database wallet-333.dat       
D:\BitcoinCore\bitcoin-0.16.0\bin\bitcoin-qt.exe in Runaway exception     

I also tried to minimize the -keypool=20 so that the wallets size will be much smaller in size, and the process of loading them is much faster.
I was suggested that this error is because each wallet.dat file is opened in the same BDB environment. The entire environment has a limited number of database locks, and it seems like 333 wallets hits that number of database locks.
The solution (which did not work) is to create a file named DB_CONFIG in the data dir, and put the following lines in that file:
set_lk_max_locks 400000
set_lk_max_objects 400000

By default it is 40000 and now 400000 (ten times more locks available)
But this gave the same results.
I tried also:
set_lg_dir database

With no luck. 
I verified this on two different Windows 10 machines with 0.15.1 and 0.16.0. Same result. It always crashes when loading the 333 wallet.
Anyone have a solution to this?
I have put the list of wallets if anyone care to reproduce: https://pastebin.com/8wHD1tL3

**Tags:** bitcoin-core, bitcoind, wallet.dat

> **Comments:**
> **username_1**: For starters, you should file a bug report.  Even if there is a limit, the client should fail gracefully when the limit is reached, instead of crashing.  https://github.com/bitcoin/bitcoin/issues  

---

## 1 answers

### Answer by username_0 on 2018-02-13. Score: 2 | Accepted answer

Ok, I found a solution. Adding 
set_lk_max_lockers 400000

Did the trick.  
https://docs.oracle.com/cd/E17276_01/html/api_reference/C/set_lk_max_lockers_parameter.html
I tested and was able to auto-create and load 932 wallets, until I hit an out of memory error:
Logging region out of memory; you may need to increase its size
DB_TXN->abort: log undo failed for LSN: 227 171878: Not enough space
PANIC: Not enough space
PANIC: DB_RUNRECOVERY: Fatal error, run database recovery
PANIC: fatal region error detected; run recovery

Setting: 
set_lg_regionmax 1048576

Resolves the above Logging region out of memory; you may need to increase its size issue.

> **Comments:**
> **username_2**: can you please tell me where you kept this `set_lk_max_lockers 400000` ?? in db.cpp ? https://github.com/bitcoin/bitcoin/blob/master/src/wallet/db.cpp#L166  
> **username_2**: I've created DB_CONFIG file in data directory of core daemon and given two values as mentioned but still its i am getting same issue daemon crashed after 250+ wallets can you please guide me or share how to use above things?  
> **username_0**: Yes DB_CONFIG  is in the datadir as far as I can recall. I think  I also minimized the `-keypool=20` (or 10). In any case  I dumped this idea and I don't recommend going that path.  
> **username_2**: So is there any otherway..?  
> **username_2**: I mean if found anything ...please suggest .. thanks..  
> **username_0**: The other way is to manually manage the private keys/wallets. It's much harder but you are not limited in any way.  

---

