wallet.dat seems not to be written properly (after startup?)

+1 vote
At the moment I try to figure out a reasonable way to setup MultiChain clustering.

Now I stumbled across the following problem:

- creating master node

- try to connect second node (slave) -> gets info (need to join)

- cp wallet.dat from master node to slave node

- connect again -> getting message: Error: wallet.dat corrupt, salvage failed


This does not happen if I do a "backupwallet" before using the original wallet.dat:


What I have noticed:

- create and start a node

- md5sum(wallet.dat) = X

- trigger backupwallet "wallet.bkp"

- md5sum(wallet.dat) == md5sum(wallet.bkp) != X

So the wallet.dat changes after triggering backupwallet, and then I am also able to copy the original wallet.dat to the second node and the currupt error is gone.


I don't know what exactly is wrong here, but it seems that the wallet.dat is not usable until it is written again (in my case after triggering backupwallet, since this does not only write the backup but also changes the original wallet.dat)


Any idea?
asked Feb 28, 2018 by Alexoid

2 Answers

+1 vote

We've looked into this. It's related to the fact that the wallet.dat file contents are not always flushed immediately to disk. To flush, either use the backupwallet API, or else quit MultiChain. In a general sense we wouldn't recommend copying any of MultiChain's storage files while it is running, because you never know if you might catch them in the middle of an update.

answered Mar 1, 2018 by MultiChain

Thanks for the response.

The problem is, I can neither quit multichain nor trigger backupwallet in normal operation of our service since it is not whitelisted. (there is no way to use backupwallet e.g. locally when it is not whitelisted, right?)

The copying wouldn't be a problem, since I do a hash comparison after making a copy of wallet.dat.

Since I do a immediate backup of the wallet.dat after an instance of multichain is created it seems that most of the wallet restores wouldn't work.

Will this be fixed?

Otherwise I do not know how to backup a wallet of a multichain service after it has been created.

Yes, we should be able to fix this, to flush the wallet's contents immediately after it's created.
That would be great, thank you!

When can one expect multichain 1.0.5 with this issue beeing fixed?
We expect it to be released with the next alpha of MultiChain 2.0, which is now in development and should come out in May or June. If this timing is an issue let us know and we'll see about making a special build with just this issue fixed.

Thanks for the information and the offer.

I will get back if this is an issue.

0 votes
Version 1.0.5 of MultiChain has just been released, which should resolve this problem.
answered Jun 7, 2018 by MultiChain