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！
RPCExamples{
            "\nAdd a multisig address from 2 addresses\n"
            + HelpExampleCli("addmultisigaddress", "2 \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"") +
            "\nAs a JSON-RPC call\n"
            + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"" + EXAMPLE_ADDRESS[0] + "\\\",\\\"" + EXAMPLE_ADDRESS[1] + "\\\"]\"")
                },
            }.Check(request);
    LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet);
    auto locked_chain = pwallet->chain().lock();
    LOCK2(pwallet->cs_wallet, spk_man.cs_KeyStore);
    std::string label;
    if (!request.params[2].isNull())
        label = LabelFromValue(request.params[2]);
    int required = request.params[0].get_int();
    
    const UniValue& keys_or_addrs = request.params[1].get_array();
    std::vector<CPubKey> pubkeys;
    for (unsigned int i = 0; i < keys_or_addrs.size(); ++i) {
        if (IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].get_str().length() == 66 || keys_or_addrs[i].get_str().length() == 130)) {
            pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str()));
        } else {
            pubkeys.push_back(AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
        }
    }
    OutputType output_type = pwallet->m_default_address_type;
    if (!request.params[3].isNull()) {
        if (!ParseOutputType(request.params[3].get_str(), output_type)) {
            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[3].get_str()));
        }
    }