From 96132ddc15eaf4af10a7879dd236648600a01d7b Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 11 Aug 2016 15:25:18 -0500 Subject: [PATCH] Fix the "Received a DML command for session < sessionID > while still processing a command for the same sessionID" error --- dmlproc/dmlprocessor.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/dmlproc/dmlprocessor.cpp b/dmlproc/dmlprocessor.cpp index 3ff861f6a..3444a84b2 100644 --- a/dmlproc/dmlprocessor.cpp +++ b/dmlproc/dmlprocessor.cpp @@ -1058,6 +1058,17 @@ void PackageHandler::run() result.result=DMLPackageProcessor::COMMAND_ERROR; result.message = message; } + + // We put the packageHandler into a map so that if we receive a + // message to affect the previous command, we can find it. + // We need to remove it from the list before sending the response back. + // If we remove it after sending the results, it's possible for a commit + // or rollback be sent and get processed before it is removed, and that + // will fail. + boost::mutex::scoped_lock lk2(DMLProcessor::packageHandlerMapLock); + DMLProcessor::packageHandlerMap.erase(getSessionID()); + lk2.unlock(); + // send back the results messageqcpp::ByteStream results; messageqcpp::ByteStream::octbyte rowCount = result.rowCount; @@ -1561,9 +1572,10 @@ void DMLProcessor::operator()() php->run(); // Operates in this thread. - lk2.lock(); - packageHandlerMap.erase(sessionID); - lk2.unlock(); +// Move this to the end of PackageHandler so it is removed from the map before the response is sent +// lk2.lock(); +// packageHandlerMap.erase(sessionID); +// lk2.unlock(); } } else @@ -1597,9 +1609,10 @@ void DMLProcessor::operator()() php->run(); // Operates in this thread. - lk2.lock(); - packageHandlerMap.erase(sessionID); - lk2.unlock(); +// Move this to the end of PackageHandler so it is removed from the map before the response is sent +// lk2.lock(); +// packageHandlerMap.erase(sessionID); +// lk2.unlock(); } } }