importaddress / importmulti block any further requests until those done. #12858

issue AdamSEY opened this issue on April 2, 2018
  1. AdamSEY commented at 11:49 AM on April 2, 2018: none

    I have ubuntu server running Bitcoin core v0.16.

    I'm sending RPC calls asynchronously, but, e.g., if I'm importing 1000 address using importmulti or importaddress command, any further commands such listunspent are waits until importing command finish, Even though I have set rpcthreads=100 rpcworkqueue=50 and I've powerful server.

  2. fanquake added the label RPC/REST/ZMQ on Apr 2, 2018
  3. promag commented at 1:15 PM on April 2, 2018: member

    The current implementation locks the wallet while importing, so any other wallet call will wait until the lock is released. Thread count doesn't matter here.

  4. AdamSEY commented at 2:01 PM on April 2, 2018: none

    Why locking wallet in necessary, especially when we are importing watch-only addresses? comment out this line could resolve my problem, right? https://github.com/bitcoin/bitcoin/blob/3de01268b7048a9c85f31dc6d21d44b727e860a5/src/wallet/rpcdump.cpp#L1174

  5. sipa commented at 3:50 PM on April 2, 2018: member

    @AdamSEY No, it would introduce a bug. Whenever shared data structures are accessed, locking is necessary.

  6. sipa closed this on Apr 2, 2018

  7. AdamSEY commented at 5:04 PM on April 2, 2018: none

    @sipa Does importaddress lock the wallet? Can you suggest any solution to import a thousand address and use the other commands?

  8. promag commented at 5:37 PM on April 2, 2018: member

    If those commands interact with the wallet then, currently, there is no solution.

  9. sipa commented at 5:54 PM on April 2, 2018: member

    @AdamSEY I don't know what you're trying to do, but if the time a rescan takes is an issue, perhaps you should change your workflow so it does not rely on importing existing addresses or keys?

  10. AdamSEY commented at 6:12 PM on April 2, 2018: none

    Yeah, Thanks for the replies and help @promag @sipa. The addresses I'm importing are new, and I'm not doing a rescan. What brought my attention. If the addresses are new, no rescan required, and it's watch-only addresses then Why are we blocking wallet access? Importing 20 address takes 4.5s! And If we're doing listunspent at the same time, I have to wait for the import to finish.

    But you are right; I have to change my workflow!

  11. sipa commented at 6:19 PM on April 2, 2018: member

    Wow, it shouldn't take that long if you're not rescanning. That sounds like an issue.

    Not the fact that it blocks (that's kind of inevitable), but I don't understand why it takes that long regardless.

  12. AdamSEY commented at 6:23 PM on April 2, 2018: none

    Perhaps because I have imported too many addresses before?

  13. AdamSEY commented at 7:41 PM on April 2, 2018: none

    I've removed the wallet.dat and tried to import 20 addresses but importing time is the same

    It took 4.4455699920654 seconds!

    So it seems not because I've imported many addresses. Should I open a different issue for that problem or we just open this one again since there are many details.

  14. MarcoFalke locked this on Sep 8, 2021
Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me