<!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->
<!-- Describe the issue -->
When the dbcache is set to 6000, and a re-index is run, bitcoin becomes frozen when the -flushStateToDisk is run. Looks like the network becomes unresponsive. Bitcoin must be force-quit. On restarting, Bitcoin is still frozen. However, opening Bitcoin with -reindex Bitcoin is responsive. Setting the dbcache to 1000 seems to work.
Expected behavior
<!--- What behavior did you expect? -->
I expected to be able to set as much memory as I want in relation to my system resources. Or for the software to limit the amount of memory I can set if it can't handle using more memory. Ideally, I want to store as much in memory as possible to reduce disk I/O. Or for the cache to get rid of data by least used instead of flushing the entire cache when it gets full.
Actual behavior Bitcoin freezes if it's trying to flush to cache and other operations timeout.
<!--- What was the actual behavior (provide screenshots if the issue is GUI-related)? -->
To reproduce I've reproduced this multiple times using 4000 & 6000 as the dbcache memory and then performing a -reindex.
System information 2010 Mac 5,1 10.13.6 os 2.8 GHz Quad-Core Intel Xeon 24 GB 1066 MHz DDR3 ATI Radeon HD 5870 1024 MB blockchain stored on an attached DroboPro with 5 TB free storage.
<!-- What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)? -->
Bitcoin 0.20
<!-- What type of machine are you observing the error on (OS/CPU and disk type)? -->
<!-- GUI-related issue? What is your operating system and its version? If Linux, what is your desktop environment and graphical shell? -->
<!-- Any extra information that might be useful in the debugging process. -->
2020-06-22T09:45:03Z UpdateTip: new best=0000000000000000001bd8ac88048e8e8e3f06a0e3d0fe355ab6eaffa48e97d0 height=464789 version=0x20000000 log2_work=86.378173 tx=218984828 date='2017-05-04T11:38:29Z' progress=0.405148 cache=6266.1MiB(47558649txo) 2020-06-22T09:45:03Z UpdateTip: new best=00000000000000000069a73a223892fafea19580ed8e641ca170f24637294dc2 height=464790 version=0x20000000 log2_work=86.378205 tx=218987113 date='2017-05-04T11:40:53Z' progress=0.405152 cache=6266.1MiB(47558116txo) 2020-06-22T09:45:04Z Pre-allocating up to position 0x600000 in rev00864.dat 2020-06-22T09:45:04Z UpdateTip: new best=000000000000000001857d2f936feeb7fec6ff919c9dd66175602570d27d55da height=464791 version=0x20000000 log2_work=86.378237 tx=218989446 date='2017-05-04T11:49:23Z' progress=0.405156 cache=6266.3MiB(47559641txo) 2020-06-22T09:45:04Z UpdateTip: new best=000000000000000001ec00e7d7e1b62824225de84866f7cd107bc18ec7e9fbff height=464792 version=0x20000002 log2_work=86.378269 tx=218991636 date='2017-05-04T12:02:06Z' progress=0.405160 cache=6266.5MiB(47561527txo) 2020-06-22T09:45:04Z UpdateTip: new best=000000000000000001de73c635f9b1ab815f7c900bad2acfed007e9e2472e059 height=464793 version=0x20000000 log2_work=86.378302 tx=218994371 date='2017-05-04T12:04:12Z' progress=0.405165 cache=6266.5MiB(47561940txo) 2020-06-22T09:45:06Z FlushStateToDisk: write coins cache to disk (47561940 coins, 6570934kB) started 2020-06-22T10:04:05Z ping timeout: 1200.044857s 2020-06-22T10:04:22Z ping timeout: 1200.036871s 2020-06-22T10:04:41Z ping timeout: 1200.000604s 2020-06-22T10:04:51Z ping timeout: 1200.035362s 2020-06-22T10:04:51Z ping timeout: 1200.013015s 2020-06-22T10:04:52Z socket receive timeout: 1201s 2020-06-22T10:04:55Z ping timeout: 1200.055899s 2020-06-22T10:04:57Z socket receive timeout: 1201s 2020-06-22T10:04:59Z ping timeout: 1200.011840s 2020-06-22T10:05:00Z socket receive timeout: 1201s 2020-06-22T10:39:38Z FlushStateToDisk: write coins cache to disk (47561940 coins, 6570934kB) completed (3272.20s) 2020-06-22T10:39:38Z New outbound peer connected: version: 70015, blocks=635832, peer=60 (full-relay) 2020-06-22T10:39:39Z Synchronizing blockheaders, height: 635832 (~100.00%) 2020-06-22T10:39:50Z New outbound peer connected: version: 70015, blocks=635832, peer=61 (full-relay) 2020-06-22T10:41:23Z UpdateTip: new best=000000000000000001d22964dfe71f45bda0a4468987c5445d84297eddba5eed height=464794 version=0x20000000 log2_work=86.378334 tx=218996634 date='2017-05-04T12:15:03Z' progress=0.405161 cache=403.0MiB(8699txo) 2020-06-22T10:43:01Z UpdateTip: new best=00000000000000000131e4da5107b671c3fd6d300dd9a5cd42d46ba1f703785e height=464795 version=0x20000002 log2_work=86.378366 tx=218999276 date='2017-05-04T12:15:30Z' progress=0.405166 cache=404.1MiB(17850txo) 2020-06-22T10:45:11Z UpdateTip: new best=00000000000000000200288ea0ce4368518127ead0042fb0ef8de1420c446eb4 height=464796 version=0x20000002 log2_work=86.378398 tx=219000961 date='2017-05-04T12:20:36Z' progress=0.405169 cache=405.1MiB(25769txo) 2020-06-22T10:46:39Z UpdateTip: new best=000000000000000000e7441ceedce232e8eac8a4c2fdf292c42fb8616e74be11 height=464797 version=0x20000000 log2_work=86.37843 tx=219002941 date='2017-05-04T12:29:39Z' progress=0.405172 cache=405.9MiB(32457txo) 2020-06-22T10:48:29Z UpdateTip: new best=0000000000000000019a8f214dcc8cd8f77457020414e7e92fc4f5ac1c82bd34 height=464798 version=0x20000000 log2_work=86.378462 tx=219005030 date='2017-05-04T12:42:25Z' progress=0.405176 cache=406.7MiB(39539txo) 2020-06-22T10:49:50Z UpdateTip: new best=00000000000000000094d2cf1381df2459e4518dd1179b6c2853758078a60a08 height=464799 version=0x20000000 log2_work=86.378495 tx=219007568 date='2017-05-04T12:52:21Z' progress=0.405180 cache=407.6MiB(46835txo)
log2_work=83.17013 tx=78829608 date='2015-08-05T04:28:10Z' progress=0.146193 cache=4369.5MiB(32124795txo) 2020-06-17T21:21:19Z UpdateTip: new best=00000000000000000cf6723f7e0b036c723f54cdb8de4c62cbd3cdeb1611e74b height=368461 version=0x00000003 log2_work=83.17016 tx=78830673 date='2015-08-05T04:34:46Z' progress=0.146195 cache=4371.6MiB(32141541txo) 2020-06-17T21:21:19Z Cache size (4585634368) exceeds total space (4584481536) 2020-06-17T21:21:26Z FlushStateToDisk: write coins cache to disk (32154910 coins, 4585634kB) started 2020-06-17T21:40:07Z socket sending timeout: 1201s 2020-06-17T21:40:08Z socket sending timeout: 1201s 2020-06-17T21:40:18Z socket sending timeout: 1201s 2020-06-17T21:40:24Z socket sending timeout: 1201s 2020-06-17T21:40:36Z socket sending timeout: 1201s 2020-06-17T21:40:47Z socket sending timeout: 1201s 2020-06-17T21:40:52Z socket sending timeout: 1201s 2020-06-17T21:41:01Z socket sending timeout: 1201s 2020-06-17T21:41:18Z socket sending timeout: 1201s 2020-06-17T22:02:46Z Fatal LevelDB error: Corruption: block checksum mismatch: /Volumes/Drobo/bitcoin/chainstate/000951.ldb 2020-06-17T22:02:46Z You can use -debug=leveldb to get more complete diagnostic messages 2020-06-17T22:02:46Z FlushStateToDisk: write coins cache to disk (32154910 coins, 4585634kB) completed (2479.23s) 2020-06-17T22:02:46Z *** System error while flushing: Fatal LevelDB error: Corruption: block checksum mismatch: /Volumes/Drobo/bitcoin/chainstate/000951.ldb 2020-06-17T22:02:46Z Error: A fatal internal error occurred, see debug.log for details
2020-06-16T16:00:26Z UpdateTip: new best=000000000000000002b58084257da688a7e94278653c095534d1053b3fa922f2 height=444197 version=0x20000002 log2_work=85.698989 tx=180393857 date='2016-12-19T21:54:48Z' progress=0.334765 cache=5993.3MiB(45258820txo) 2020-06-16T16:00:26Z UpdateTip: new best=0000000000000000022e23f5c9411119c0d22819bfc6d73a1af4612a7c5f893c height=444198 version=0x20000000 log2_work=85.69902 tx=180395940 date='2016-12-19T22:04:22Z' progress=0.334769 cache=5993.6MiB(45260611txo) 2020-06-16T16:00:26Z FlushStateToDisk: write coins cache to disk (45260611 coins, 6284711kB) started 2020-06-16T16:19:08Z ping timeout: 1200.012257s 2020-06-16T16:19:41Z ping timeout: 1200.033777s 2020-06-16T16:19:57Z ping timeout: 1200.024535s 2020-06-16T16:20:00Z ping timeout: 1200.016487s 2020-06-16T16:20:15Z ping timeout: 1200.051644s 2020-06-16T16:20:21Z socket receive timeout: 1201s 2020-06-16T16:20:23Z socket receive timeout: 1201s 2020-06-16T16:20:24Z socket sending timeout: 1201s 2020-06-16T16:20:24Z socket sending timeout: 1201s 2020-06-16T16:20:24Z socket sending timeout: 1201s 2020-06-16T17:19:33Z FlushStateToDisk: write coins cache to disk (45260611 coins, 6284711kB) completed (4746.67s) 2020-06-16T17:19:35Z New outbound peer connected: version: 70015, blocks=635041, peer=70 (full-relay) 2020-06-16T17:19:35Z Synchronizing blockheaders, height: 635041 (~100.00%) 2020-06-16T17:33:47Z UpdateTip: new best=00000000000000000354224e259caf19203cc73071c7e2e72d0c1f1876ea1c52 height=444199 version=0x20000000 log2_work=85.69905 tx=180398107 date='2016-12-19T22:13:09Z' progress=0.334761 cache=403.0MiB(8521txo) 2020-06-16T17:42:45Z Pre-allocating up to position 0x700000 in rev00714.dat 2020-06-16T17:42:46Z UpdateTip: new best=000000000000000002fe6fc19c8869e87903b0ee283b59cd5c4c459a525189e1 height=444200 version=0x20000002 log2_work=85.699081 tx=180400491 date='2016-12-19T22:55:41Z' progress=0.334765 cache=404.0MiB(16944txo) 2020-06-16T17:42:46Z socket sending timeout: 1391s
2020-06-21T12:24:10Z UpdateTip: new best=000000000000000011897d150f3728c866fa2f6684835b78355c58d5dbe930ba height=368333 version=0x00000003 log2_work=83.166345 tx=78700744 date='2015-08-04T04:03:31Z' progress=0.145674 cache=4275.4MiB(31354186txo) 2020-06-21T12:24:11Z UpdateTip: new best=000000000000000014a29f0c88cc294040eab592d157f7de2b5892cf97b01d83 height=368334 version=0x00000003 log2_work=83.166375 tx=78702947 date='2015-08-04T04:07:36Z' progress=0.145678 cache=4275.6MiB(31355529txo) 2020-06-21T12:24:11Z Cache size (4484909120) exceeds total space (4483818240) 2020-06-21T12:24:17Z FlushStateToDisk: write coins cache to disk (31368187 coins, 4484909kB) started 2020-06-21T12:42:48Z FlushStateToDisk: write coins cache to disk (31368187 coins, 4484909kB) completed (1110.84s) 2020-06-21T12:42:48Z UpdateTip: new best=00000000000000000a82957664d9a33a5f777b7b6785bfad8a6585b41ab6b572 height=368335 version=0x00000003 log2_work=83.166405 tx=78704222 date='2015-08-04T04:25:51Z' progress=0.145680 cache=401.9MiB(0txo) 2020-06-21T12:42:48Z socket send error Broken pipe (32) 2020-06-21T12:42:55Z UpdateTip: new best=00000000000000000aabab5f0c494d6614738ecddd5c205f2e882e3c566a56b8 height=368336 version=0x00000003 log2_work=83.166434 tx=78704223 date='2015-08-04T04:26:45Z' progress=0.145680 cache=401.9MiB(1txo) 2020-06-21T12:42:58Z UpdateTip: new best=00000000000000000f36e58fc5ab131a96d5114b5e9906f8a6a9486cc287d30c height=368337 version=0x00000003 log2_work=83.166464 tx=78704765 date='2015-08-04T04:27:48Z' progress=0.145681 cache=402.4MiB(4211txo) 2020-06-21T12:42:59Z Pre-allocating up to position 0x100000 in rev00314.dat
<!--- This is normally the contents of a `debug.log` or `config.log` file. Raw text or a link to a pastebin type site are preferred. -->