Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Jun 2, 2020

level 0,1,2, and 3 are already interruptible, so make level 4 also interruptible

@maflcko
Copy link
Member Author

maflcko commented Jun 2, 2020

(intentionally left empty)

@fanquake
Copy link
Member

fanquake commented Jun 3, 2020

Concept ACK

In fa6e9b84ef25b266729dd03337ae00c0ab44e52a:

ActivateBestChain is only called in the "msghand" or one of the RPC
threads, neither of which is a boost::thread.

Is this correct? ActivateBestChain() is also called by ThreadImport(), both directly as well via LoadExternalBlockFile. ThreadImport is run in the boost::thread_group:

bitcoin/src/init.cpp

Lines 1847 to 1849 in 657b82c

threadGroup.create_thread([=, &chainman] { ThreadImport(chainman, vImportFiles); });

VerifyDB is only called in the main thread ("init") or one of the RPC
threads, neither of which is a boost::thread.

Checked that the calls to CVerifyDB().VerifyDB() are in the init thread and verifychain RPC call.

@maflcko
Copy link
Member Author

maflcko commented Jun 3, 2020

Is this correct? ActivateBestChain() is also called by ThreadImport(), both directly as well via LoadExternalBlockFile. ThreadImport is run in the boost::thread_group:

Good catch, you are correct. However, after #18786 (init: Remove boost from ThreadImport), it should be possible to simply switch ThreadImport to a std::thread. Also see that in line 2929 there is another non-boost breakpoint: if (ShutdownRequested()) break;.

I will adjust the commit message accordingly.

MarcoFalke added 2 commits June 3, 2020 06:06
ActivateBestChain (ABC) is only called in the "msghand" or one of the
RPC threads, neither of which is a boost::thread. However, ABC is also
called in ThreadImport (which currently happens to be a boost::thread).
In all cases, the interruption_point is redundant with the breakpoint in
ABC that triggers when ShutdownRequested()

VerifyDB is only called in the main thread ("init") or one of the RPC
threads, neither of which is a boost::thread.
@maflcko maflcko force-pushed the 2006-valVerifyDbInterrupt4 branch from faed13e to fa3b4f9 Compare June 3, 2020 10:07
@maflcko
Copy link
Member Author

maflcko commented Jun 3, 2020

Done. Force pushed a commit message change:

$ git range-diff bitcoin-core/master  faed13ea16 fa3b4f9b8e
1:  fa6e9b84ef ! 1:  fa1d5800d9 validation: Remove unused boost interruption_point
    @@ Metadata
      ## Commit message ##
         validation: Remove unused boost interruption_point
     
    -    ActivateBestChain is only called in the "msghand" or one of the RPC
    -    threads, neither of which is a boost::thread.
    +    ActivateBestChain (ABC) is only called in the "msghand" or one of the
    +    RPC threads, neither of which is a boost::thread. However, ABC is also
    +    called in ThreadImport (which currently happens to be a boost::thread).
    +    In all cases, the interruption_point is redundant with the breakpoint in
    +    ABC that triggers when ShutdownRequested()
     
         VerifyDB is only called in the main thread ("init") or one of the RPC
         threads, neither of which is a boost::thread.
2:  faed13ea16 = 2:  fa3b4f9b8e validation: Make VerifyDB level 4 interruptible

@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 4, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@laanwj
Copy link
Member

laanwj commented Jun 4, 2020

Code review ACK fa3b4f9
Thank you for cleaning up more boost interruption point usage.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK fa3b4f9

I will adjust the commit message accordingly.

Thanks.

Rechecked that a call to verifychain is interrupted:

diff --git a/src/validation.cpp b/src/validation.cpp
index 1ce440dc0..6e813e00a 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4337,7 +4337,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
                 return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
             if (!::ChainstateActive().ConnectBlock(block, state, pindex, coins, chainparams))
                 return error("VerifyDB(): *** found unconnectable block at %d, hash=%s (%s)", pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
-            if (ShutdownRequested()) return true;
+            //if (ShutdownRequested()) return true;
         }
     }
2020-06-04T13:04:33.970347Z [msghand] New outbound peer connected: version: 70015, blocks=633028, peer=17 (block-relay)
2020-06-04T13:04:47.234325Z [httpworker.0] Verifying last 100 blocks at level 4
2020-06-04T13:04:47.234376Z [httpworker.0] [0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...tor: Thread interrupt
2020-06-04T13:05:11.967041Z [init] Shutdown: In progress...
2020-06-04T13:05:11.967992Z [addcon] addcon thread exit
2020-06-04T13:05:11.971026Z [torcontrol] torcontrol thread exit
2020-06-04T13:05:11.978165Z [opencon] opencon thread exit
2020-06-04T13:05:11.979705Z [net] net thread exit
2020-06-04T13:05:13.444961Z [httpworker.0] [70%]...[80%]...[90%]...[DONE].
2020-06-04T13:05:21.697665Z [httpworker.0] No coin database inconsistencies in last 100 blocks (187923 transactions)
2020-06-04T13:05:21.786008Z [msghand] msghand thread exit
2020-06-04T13:05:21.948084Z [scheduler] scheduler thread exit
2020-06-04T13:05:21.988007Z [shutoff] Writing 0 unbroadcast transactions to disk.
2020-06-04T13:05:22.000826Z [shutoff] Dumped mempool: 0.001229s to copy, 0.024559s to dump
2020-06-04T13:05:22.032434Z [shutoff] FlushStateToDisk: write coins cache to disk (272667 coins, 38381kB) started
2020-06-04T13:05:22.189725Z [shutoff] FlushStateToDisk: write coins cache to disk (272667 coins, 38381kB) completed (0.16s)
2020-06-04T13:05:22.227430Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 3292kB) started
2020-06-04T13:05:22.227563Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 3292kB) completed (0.00s)
2020-06-04T13:05:22.289343Z [shutoff] [default wallet] Releasing wallet
2020-06-04T13:05:22.294110Z [shutoff] Shutdown: done

This PR

2020-06-04T13:26:17.699492Z [msghand] New outbound peer connected: version: 70015, blocks=633028, peer=8 (full-relay)
2020-06-04T13:26:39.372328Z [httpworker.0] Verifying last 100 blocks at level 4
2020-06-04T13:26:39.372380Z [httpworker.0] [0%]...[10%]...[20%]...[30%]...[40%]...[50%]...[60%]...tor: Thread interrupt
2020-06-04T13:27:24.895974Z [addcon] addcon thread exit
2020-06-04T13:27:24.896071Z [torcontrol] torcontrol thread exit
2020-06-04T13:27:24.896148Z [init] Shutdown: In progress...
2020-06-04T13:27:24.905837Z [net] net thread exit
2020-06-04T13:27:24.969283Z [msghand] msghand thread exit
2020-06-04T13:27:24.969452Z [opencon] opencon thread exit
2020-06-04T13:27:25.134754Z [scheduler] scheduler thread exit
2020-06-04T13:27:25.174710Z [shutoff] Writing 0 unbroadcast transactions to disk.
2020-06-04T13:27:25.186320Z [shutoff] Dumped mempool: 0.001838s to copy, 0.02701s to dump
2020-06-04T13:27:25.217315Z [shutoff] FlushStateToDisk: write coins cache to disk (273951 coins, 38546kB) started
2020-06-04T13:27:25.389811Z [shutoff] FlushStateToDisk: write coins cache to disk (273951 coins, 38546kB) completed (0.17s)
2020-06-04T13:27:25.424695Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 3292kB) started
2020-06-04T13:27:25.424895Z [shutoff] FlushStateToDisk: write coins cache to disk (0 coins, 3292kB) completed (0.00s)
2020-06-04T13:27:25.492179Z [shutoff] [default wallet] Releasing wallet
2020-06-04T13:27:25.497838Z [shutoff] Shutdown: done

@fanquake fanquake merged commit 584170a into bitcoin:master Jun 4, 2020
@maflcko maflcko deleted the 2006-valVerifyDbInterrupt4 branch June 4, 2020 14:00
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 4, 2020
fa3b4f9 validation: Make VerifyDB level 4 interruptible (MarcoFalke)
fa1d580 validation: Remove unused boost interruption_point (MarcoFalke)

Pull request description:

  level 0,1,2, and 3 are already interruptible, so make level 4 also interruptible

ACKs for top commit:
  laanwj:
    Code review ACK fa3b4f9
  fanquake:
    ACK fa3b4f9

Tree-SHA512: d302c84a17add1b5993dd78339c88670d27eee45ce208c4d046ae188b50be9843ee5a9584739d5d25453b54ae08fd1cb6eeee8cb1307d84c05cde8a54a7c445b
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
fanquake added a commit to fanquake/bitcoin that referenced this pull request Jun 12, 2020
Mentioned in bitcoin#19142, which removed the boost::interruption_point()
in ThreadImport().
fanquake added a commit that referenced this pull request Jun 19, 2020
83fd3a6 init: use std::thread for ThreadImport() (fanquake)

Pull request description:

  [Mentioned](#19142 (comment)) in #19142, which removed the `boost::interruption_point()`
  in `ThreadImport()`.

ACKs for top commit:
  hebasto:
    ACK 83fd3a6, I have reviewed the code and it looks OK, I agree it can be merged.
  donaloconnor:
    ACK 83fd3a6
  laanwj:
    Code review ACK 83fd3a6
  MarcoFalke:
    ACK 83fd3a6

Tree-SHA512: 0644947d669feb61eed3a944012dad1bd3dd75cf994aa2630013043c213a335b162b63e20aa37e0997740d8e3a3ec367b660b5196007a09e13f0ac455b36c821
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jul 7, 2020
83fd3a6 init: use std::thread for ThreadImport() (fanquake)

Pull request description:

  [Mentioned](bitcoin#19142 (comment)) in bitcoin#19142, which removed the `boost::interruption_point()`
  in `ThreadImport()`.

ACKs for top commit:
  hebasto:
    ACK 83fd3a6, I have reviewed the code and it looks OK, I agree it can be merged.
  donaloconnor:
    ACK 83fd3a6
  laanwj:
    Code review ACK 83fd3a6
  MarcoFalke:
    ACK 83fd3a6

Tree-SHA512: 0644947d669feb61eed3a944012dad1bd3dd75cf994aa2630013043c213a335b162b63e20aa37e0997740d8e3a3ec367b660b5196007a09e13f0ac455b36c821
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Feb 24, 2021
Summary:
fa1d5800d9c5e33942b76f6667839a818723dee9
> validation: Remove unused boost interruption_point
>
> ActivateBestChain (ABC) is only called in the "msghand" or one of the
> RPC threads, neither of which is a boost::thread. However, ABC is also
> called in ThreadImport (which currently happens to be a boost::thread).
> In all cases, the interruption_point is redundant with the breakpoint in
> ABC that triggers when ShutdownRequested()
>
> VerifyDB is only called in the main thread ("init") or one of the RPC
> threads, neither of which is a boost::thread.

fa3b4f9b8e54ec07aeb2e5e2333da3e784f7be12
> validation: Make VerifyDB level 4 interruptible

This is a backport of [[bitcoin/bitcoin#19142 | core#19142]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9269
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 23, 2021
Summary:
Mentioned in [[bitcoin/bitcoin#19142 | core#19142]], which removed the boost::interruption_point()
in ThreadImport().

This is a backport of [[bitcoin/bitcoin#19197 | core#19197]]

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D9833
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants