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！
"Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
                                                          "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
                            {"lockUnspents", RPCArg::Type::BOOL,  "false", "Lock selected unspent outputs"},
                            {"feeRate", RPCArg::Type::AMOUNT,  "not set: makes wallet determine the fee", "Set a specific fee rate in " + CURRENCY_UNIT + "/kB"},
                            {"subtractFeeFromOutputs", RPCArg::Type::ARR,  "empty array", "The integers.\n"
                            "                              The fee will be equally deducted from the amount of each specified output.\n"
                            "                              Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
                            "                              If no outputs are specified here, the sender pays the fee.",
                                {
                                    {"vout_index", RPCArg::Type::NUM, RPCArg::Optional::OMITTED, "The zero-based output index, before a change output is added."},
                                },
                            },
                            {"replaceable", RPCArg::Type::BOOL,  "wallet default", "Marks this transaction as BIP125 replaceable.\n"
                            "                              Allows this transaction to be replaced by a transaction with higher fees"},
                            {"conf_target", RPCArg::Type::NUM,  "wallet default", "Confirmation target (in blocks)"},
                            {"estimate_mode", RPCArg::Type::STR,  "UNSET", "The fee estimate mode, must be one of:\n"
                            "         \"UNSET\"\n"
                            "         \"ECONOMICAL\"\n"
                            "         \"CONSERVATIVE\""},
                        },
                        "options"},
                    {"iswitness", RPCArg::Type::BOOL,  "depends on heuristic tests", "Whether the transaction hex is a serialized witness transaction.\n"
                        "If iswitness is not present, heuristic tests will be used in decoding.\n"
                        "If true, only witness deserialization will be tried.\n"
                        "If false, only non-witness deserialization will be tried.\n"
                        "This boolean should reflect whether the transaction has inputs\n"
                        "(e.g. fully valid, or on-chain transactions), if known by the caller."
                    },
                },
                RPCResult{