When i used the encrypted wallet to test transfer parallelly,i frequently got the trouble: The rpc server is not responding.My test script is like below:
#!/bin/sh
while [ 1 ]
do
./bitcoin-cli listaddressgroupings>null
./bitcoin-cli walletpassphrase "!@#$%^&*" 2
./bitcoin sendtoaddress "mhAW6mzs5DeCbzBUHXBi4U446Fdnr1z8U7" 0.01
done

When i open the dead lock trace macro and check the debug log,i found the last print is as below:
2018-12-17 08:27:58 ThreadRPCServer method=walletpassphrase
2018-12-17 08:27:58 LOCKCONTENTION: cs_main
2018-12-17 08:27:58 Locker: wallet/rpcwallet.cpp:2642
2018-12-17 08:27:58 LOCKCONTENTION: pWallet->cs_wallet
2018-12-17 08:27:58 Locker: wallet/rpcwallet.cpp:2607

The line no 2642 is walletpassphrase and 2607 is LockWallet. I checked the code,i found there is no log printed for this line in function "walletpassphrase":
"LogPrint(BCLog::RPC, "queue run of timer %s in %i seconds (using %s)\n", name, nSeconds, timerInterface->Name());" So i guess the reason may be:
When "walletpassphrase" is running and lock the cs_wallet,the last relock timer triggered and call "LockWallet"."LockWallet" want to lock the cs_wallet but it has been locked by "walletpassphrase",so "LockWallet" is blocked.When "walletpassphrase" run to call "RPCRunLater",the function will erase the timer from the std::map "deadlineTimers",but the timer's timeout call is blocked,so the dead lock take place.
Is my guess right?
How to reslove the issue?
Any help will be appreciative！
{
    std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
    const CWallet* const pwallet = wallet.get();
    if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
        return NullUniValue;
    }
            RPCHelpMan{"getreceivedbylabel",
                "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n",
                {
                    {"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The selected label, may be the default label using \"\"."},
                    {"minconf", RPCArg::Type::NUM,  "1", "Only include transactions confirmed at least this many times."},
                },
                RPCResult{
                    RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " received for this label."
                },
                RPCExamples{
            "\nAmount received by the default label with at least 1 confirmation\n"
            + HelpExampleCli("getreceivedbylabel", "\"\"") +
            "\nAmount received at the tabby label including unconfirmed amounts with zero confirmations\n"
            + HelpExampleCli("getreceivedbylabel", "\"tabby\" 0") +
            "\nThe amount with at least 6 confirmations\n"
            + HelpExampleCli("getreceivedbylabel", "\"tabby\" 6") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("getreceivedbylabel", "\"tabby\", 6")
                },
            }.Check(request);