Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: bodom on April 29, 2016, 11:17:17 PM



Title: Error opening blocks database
Post by: bodom on April 29, 2016, 11:17:17 PM
Hi there!

I have installed the Bitcoin client for Linux (bitcoin-qt).

I have started it, and it started synchronizing blocks. After a while, my disk got full.

I have then moved the ~/.bitcoin/blocks and ~/.bitcoin/chainstate to a different partition and created symlinks. The client started again and downloaded blocks for some hours, then also that partition got full.

I have a NAS mounted via cifs (smbfs) with huge disk space. If I move the blocks and chainstate folders there and symlink them, exactly in the same way i did with the other partition, I get an error opening blocks database. It asks me if I want to rebuild it. If I answer yes, it then says the same error again and exits.

Any ideas?

Thank you


Title: Re: Error opening blocks database
Post by: achow101 on April 29, 2016, 11:44:36 PM
Hi there!

I have installed the Bitcoin client for Linux (bitcoin-qt).

I have started it, and it started synchronizing blocks. After a while, my disk got full.

I have then moved the ~/.bitcoin/blocks and ~/.bitcoin/chainstate to a different partition and created symlinks. The client started again and downloaded blocks for some hours, then also that partition got full.

I have a NAS mounted via cifs (smbfs) with huge disk space. If I move the blocks and chainstate folders there and symlink them, exactly in the same way i did with the other partition, I get an error opening blocks database. It asks me if I want to rebuild it. If I answer yes, it then says the same error again and exits.

Any ideas?

Thank you

I'm pretty sure that is a problem with cifs since I have done this before and it has failed. You should really only be doing it with locally connected drives.


Title: Re: Error opening blocks database
Post by: bodom on April 30, 2016, 01:15:20 PM
Why aren't network drivers ok?  ???


Title: Re: Error opening blocks database
Post by: achow101 on April 30, 2016, 02:28:07 PM
Why aren't network drivers ok?  ???
I haven't fully investigated it yet, so I don't know why. But after some experimentation, I do know that network drives do not work.


Title: Re: Error opening blocks database
Post by: bodom on April 30, 2016, 09:45:02 PM
In theory, there should be no way for the Bitcoin software to distinguish between a local and a network drive. That's why I do not see why it should not work.

Is there a way to have a more precise error message saying what is wrong?
Is this the right place to ask support for that software?


Title: Re: Error opening blocks database
Post by: achow101 on April 30, 2016, 09:54:31 PM
In theory, there should be no way for the Bitcoin software to distinguish between a local and a network drive. That's why I do not see why it should not work.
In theory, yes. In practice, the software implementation may be doing something which differs from a local drive and causes Bitcoin Core to react in unexpected ways.

Is there a way to have a more precise error message saying what is wrong?
Those error messages are in the debug.log. Can you post that here so that we can see what the errors are? IIRC, though, the error messages for this are not all to helpful.

Is this the right place to ask support for that software?
No. The developers do not use these forms anymore. The proper place to report bugs and issues is on the github issue tracker at https://github.com/bitcoin/bitcoin/issues


Title: Re: Error opening blocks database
Post by: bodom on April 30, 2016, 10:14:49 PM
Thank you for the explanations.

I have tried doing something very weird: I have created big image file inside the network share, then mounted it.
Goods news: it works. Bad news: it is incredibly slow, as expected.

So the network itself is definitely not a problem. Could be a permissions problem?

here is the debug.log:
Code:
2016-04-30 22:11:04 Bitcoin version v0.12.1.0-g9779e1e (Mon, 11 Apr 2016 13:01:43 +0200)
2016-04-30 22:11:04 InitParameterInteraction: parameter interaction: -listen=0 -> setting -upnp=0
2016-04-30 22:11:04 InitParameterInteraction: parameter interaction: -listen=0 -> setting -discover=0
2016-04-30 22:11:04 InitParameterInteraction: parameter interaction: -listen=0 -> setting -listenonion=0
2016-04-30 22:11:04 InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2016-04-30 22:11:04 GUI: Bus::open: Can not get ibus-daemon's address.
2016-04-30 22:11:04 GUI: "sni-qt/26696" WARN  00:11:04.636 void StatusNotifierItemFactory::connectToSnw() Invalid interface to SNW_SERVICE
2016-04-30 22:11:04 Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2016-04-30 22:11:04 Default data directory /home/bodom/.bitcoin
2016-04-30 22:11:04 Using data directory /home/bodom/.bitcoin
2016-04-30 22:11:04 Using config file /home/bodom/.bitcoin/bitcoin.conf
2016-04-30 22:11:04 Using at most 125 connections (1024 file descriptors available)
2016-04-30 22:11:04 Using 4 threads for script verification
2016-04-30 22:11:04 Using wallet wallet.dat
2016-04-30 22:11:04 init message: Verifying wallet...
2016-04-30 22:11:04 scheduler thread start
2016-04-30 22:11:04 CDBEnv::Open: LogDir=/home/bodom/.bitcoin/database ErrorFile=/home/bodom/.bitcoin/db.log
2016-04-30 22:11:04 Cache configuration:
2016-04-30 22:11:04 * Using 12.5MiB for block index database
2016-04-30 22:11:04 * Using 29.9MiB for chain state database
2016-04-30 22:11:04 * Using 57.6MiB for in-memory UTXO set
2016-04-30 22:11:04 init message: Loading block index...
2016-04-30 22:11:04 Opening LevelDB in /home/bodom/.bitcoin/blocks/index
2016-04-30 22:11:04 IO error: /home/bodom/.bitcoin/blocks/index: Invalid argument
2016-04-30 22:11:06 init message: Loading block index...
2016-04-30 22:11:06 Wiping LevelDB in /home/bodom/.bitcoin/blocks/index
2016-04-30 22:11:06 Opening LevelDB in /home/bodom/.bitcoin/blocks/index
2016-04-30 22:11:06 IO error: /home/bodom/.bitcoin/blocks/index: Invalid argument
2016-04-30 22:11:07 scheduler thread interrupt
2016-04-30 22:11:07 Shutdown: In progress...
2016-04-30 22:11:07 StopNode()
2016-04-30 22:11:07 Shutdown: done

The folder giving an I/O error exists:

Code:
$stat /home/bodom/.bitcoin/blocks/index
  File: '/home/bodom/.bitcoin/blocks/index'
  Size: 0          Blocks: 0          IO Block: 16384  directory
Device: 32h/50d Inode: 74186757    Links: 2
Access: (0700/drwx------)  Uid: ( 1000/   bodom)   Gid: ( 1000/   bodom)
Access: 2016-05-01 00:11:06.264941600 +0200
Modify: 2016-05-01 00:11:06.268941500 +0200
Change: 2016-05-01 00:11:06.268941500 +0200
 Birth: -


Title: Re: Error opening blocks database
Post by: achow101 on April 30, 2016, 10:20:10 PM
So the network itself is definitely not a problem. Could be a permissions problem?
I don't think it is permissions. I think it has to do with how cifs does file sharing, although, again, I'm not sure. I'll open an issue on github since I have also had this problem before.


Title: Re: Error opening blocks database
Post by: bodom on April 30, 2016, 10:33:16 PM
So following your hints I've found these links:
https://github.com/bitcoin/bitcoin/issues/4276
https://github.com/smira/aptly/issues/317

Quote
No, this is LevelDB reporting that an internal system call returned with an error status indicating that an invalid argument was passed.

I assume that the samba filesystem does not offer certain functionality that LevelDB requires of its databases, such a certain types of locking, syncing or mmaping.

Long story short, BitCoin uses LevelDB from Google, that seems to have some "undfined" issues with cifs. They could most probably be fixed/worked around, but that would require me to report the problem to the Bitcoin devs, then they to report it upstream, wait for Google to fix it, then update the LevelDB version in Bitcoin. I bet it could take years :D

I am now exploring different solutions. At least, the image file works.

Thank you


Title: Re: Error opening blocks database
Post by: achow101 on April 30, 2016, 10:49:16 PM
Long story short, BitCoin uses LevelDB from Google, that seems to have some "undfined" issues with cifs. They could most probably be fixed/worked around, but that would require me to report the problem to the Bitcoin devs, then they to report it upstream, wait for Google to fix it, then update the LevelDB version in Bitcoin. I bet it could take years :D
I've already reported it to the devs: https://github.com/bitcoin/bitcoin/issues/7981. And since they maintain their own fork of LevelDB (https://github.com/bitcoin-core/leveldb), any fix probably has a good likelihood of making it into the next major release, 0.13. That will be in a few months though, since they usually don't have bug fixes for minor releases unless they are major problems.


Title: Re: Error opening blocks database
Post by: bodom on April 30, 2016, 10:58:19 PM
Oh, thanks.

I see it works under NFS. I am planning to use it meanwhile (if I can manage to set it up in a safe way).


Title: Re: Error opening blocks database
Post by: 2c0de on May 04, 2016, 09:13:11 PM
Oh, thanks.

I see it works under NFS. I am planning to use it meanwhile (if I can manage to set it up in a safe way).

don't never do reindex, it's a waste of time.

sure. delete blocks/ and chainstate/
let it download for a day or so, on your best computer
once it's downloaded, backup blocks/ and chainstate/

regularly backup chainstate/  , blocks/index/ , and the blocks/blk,rev.dat files whose size did grow (you don't need previous except last dat files backup twice because they never change anyway)

If your chain becomes corrupt (Error opening blocks database), simply abort and recover known good chainstate/  , blocks/index/ , and  the corresponding blocks/blk,rev.dat files

once your backup is recovered bitcoin starts nearly instantly , no reindex needed