-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
importaddress when walletnotify is set, causes the notification of large number of unrelated transactions #6095
Comments
It should only notify for transactions for the address(es) that you Can you add concrete steps to reproduce? |
I did this in -regtest mode. So, run bitcoind -regtest -daemon. Generate a few blocks:
Generate a random address and import it:
And now you get a flurry of transactions being notified. Sometimes it exhausts all memory in my laptop and crashes it. |
Exhausting all memory and crashing is the fault of your implementation. walletnotify is firing off many near-simultaneous processes, each of which is probably doing a RPC query in return to bitcoind. bitcoind services only 4 simultaneous RPC connections (almost true), certain things can cause all the queries to stall, and the responses can be fairly slow. Increasing your resource limits wouldn't hurt but doing so won't fix the real problem. Responding to every walletnotify in parallel might be a bad idea. Maybe you need whatever walletnotify is doing to finish instantly after adding the txid to an queue, and have a separate event loop that processes them one at a time. |
Here's another way to understand it ... |
Oh wait ... if #6084 If your system is running out of memory and crashing from your regtest example of only 50 transactions, it is entirely possible it could die during normal operation if hit quickly enough. |
RPC might be stuck entirely during the importaddress rescan, thereby guaranteeing all the walletnotify processes will be stuck if they are waiting for RPC to respond. Queuing the RPC commands for one at a time execution would safely handle this. |
If the complaint in #6084 for |
I wonder how one address, which is actually an entirely new one (participating in no transactions whatsoever) leads to walletnotify calling my handler program repetitively -- a large number of times -- filling up the process table with I don't know how many new processes, and while eventually depriving every other process of CPU time. Furthermore, it sends me loads of transactions from the coinbase, because bitcoind may contain at that point -- in regtest -- only 1 or 2 non-coinbase transactions.Why does it need to send me all those coinbase transactions? |
I explained above that your system failing is an indication that you implemented it wrong, as it is entirely possible for many transactions to appear on your node near simultaneously during normal operation. I suggested one way to make your system more robust against that possibility. There may be room for improvement in the behavior of particularly |
It concerns a newly-generated address that has not participated in any transaction. When I do |
https://en.bitcoin.it/wiki/How_to_import_private_keys#Import_Private_key.28s.29 |
@eriksank The I do not think this is a bug. Maybe it could be explicitly mentioned in the |
... or should we change the code to run To me, it looks pretty stupid to run external shell script on bulk scan anyway... But the only bug is that the user doesn't expect it to happen. |
@paveljanik, I am actually quite ok with the workaround suggested by @wtogami in which I just call the |
Is this still an issue? There has been no further discussion on it for nearly 3 years |
Actually, no. Closing the issue. Thanks for inquiring. |
When using importaddress, walletnotify will cause the notification of a large number of unrelated transactions, triggering hundreds of processes and even crash bitcoind by making the server run out of memory.
The text was updated successfully, but these errors were encountered: