Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC stop command cannot shutdown DB cleanly #660

Closed
randydu opened this issue Nov 30, 2018 · 4 comments

Comments

@randydu
Copy link

commented Nov 30, 2018

When syncing BitcoinCash, I issue "electrumx_rpc stop" to stop the server, it reports the shutdown is complete, but when the server starts up, it declares "DB shut down uncleanly" and takes some time to scan history flushes.

INFO:DB:flushed filesystem data in 0.04s
INFO:History:flushed history in 3.3s for 1,149,624 addrs
INFO:DB:flush #370 took 3.3s.  Height 524,786 txs: 248,690,206 (+730,705)
INFO:DB:tx/sec since genesis: 1,356, since last flush: 2,903
INFO:DB:sync time: 2d 02h 56m  ETA: 01h 24m 02s
INFO:BlockProcessor:our height: 525,543 daemon: 558,781 UTXOs 441MB hist 32MB
INFO:BlockProcessor:our height: 526,759 daemon: 558,781 UTXOs 465MB hist 80MB
INFO:BlockProcessor:our height: 527,646 daemon: 558,781 UTXOs 481MB hist 130MB
INFO:BlockProcessor:our height: 528,601 daemon: 558,781 UTXOs 500MB hist 170MB
INFO:BlockProcessor:our height: 529,147 daemon: 558,781 UTXOs 512MB hist 196MB
INFO:BlockProcessor:our height: 530,018 daemon: 558,781 UTXOs 529MB hist 231MB
INFO:LocalRPC:[0] RPC 127.0.0.1:34868, 1 total
INFO:Controller:shutting down
INFO:SessionManager:closing down RPC listening servers
INFO:BlockProcessor:flushing to DB for a clean shutdown...
INFO:Controller:shutdown complete

When the server starts:

INFO:Controller:Python version: 3.7.1 (default, Nov 16 2018, 06:29:01) 
[GCC 6.4.0]
INFO:Controller:software version: ElectrumX 1.8.12
INFO:Controller:aiorpcX version: 0.10.1
INFO:Controller:supported protocol versions: 1.2-1.4
INFO:Controller:event loop policy: None
INFO:Controller:reorg limit is 200 blocks
INFO:Daemon:daemon #1 at bch:8332/ (current)
INFO:DB:switching current directory to /data
INFO:DB:using leveldb for DB backend
INFO:DB:opened UTXO DB (for sync: True)
INFO:DB:DB version: 6
INFO:DB:coin: BitcoinCash
INFO:DB:network: mainnet
INFO:DB:height: 512,729
INFO:DB:tip: 000000000000000001737461a98c3dec39e8c27766f1166f26aabb2313864607
INFO:DB:tx count: 246,695,069
INFO:DB:flushing DB cache at 1,200 MB
INFO:DB:sync time so far: 2d 02h 56m
INFO:History:history DB version: 0
INFO:History:flush count: 370
INFO:History:DB shut down uncleanly.  Scanning for excess history flushes...

INFO:History:deleting 3,332,383 history entries

INFO:History:deleted excess history entries

INFO:SessionManager:RPC server listening on 127.0.0.1:8088

INFO:Prefetcher:catching up to daemon height 558,783 (46,054 blocks behind)
@randydu

This comment has been minimized.

Copy link
Author

commented Nov 30, 2018

After the DB is fully synchronized with latest blockchain and reopened for serving, the stop command can terminate the server gracefully.

So the issue only occurs when the DB is in the process of syncing with blockchain.

@a123b

This comment has been minimized.

Copy link

commented Jan 12, 2019

I've ran into the same issue by sending SIGTERM to the server process while it was still doing its initial sync.
A few minutes after printing
INFO:BlockProcessor:flushing to DB for a clean shutdown...
the process stopped, when I restarted it, it said:
INFO:History:DB shut down uncleanly. Scanning for excess history flushes...

It also lost quite a bit of progress because of this, which unfortunately makes this issue pretty annoying.

@kyuupichan

This comment has been minimized.

Copy link
Owner

commented Feb 17, 2019

Given I've had this reported several times I'm marking this as a bug; I've not looked into it though. The fix is, I hope, trivial

@kyuupichan kyuupichan self-assigned this Feb 17, 2019

@kyuupichan kyuupichan added the bug label Feb 17, 2019

@kyuupichan kyuupichan added this to the 1.9.6 milestone Feb 17, 2019

@kyuupichan

This comment has been minimized.

Copy link
Owner

commented Feb 18, 2019

This was a silly oversight; the code to perform a clean shutdown was correctly triggered; the problem was nothing waited for it to finish...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.