You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by sa...@apache.org on 2018/06/07 22:17:35 UTC
[2/3] trafodion git commit: Address review comments
Address review comments
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/bf8d8d6c
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/bf8d8d6c
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/bf8d8d6c
Branch: refs/heads/master
Commit: bf8d8d6ca1442fced0e99e442c64416dd6bd6e0e
Parents: b041abd
Author: Sandhya Sundaresan <sa...@apache.org>
Authored: Wed Jun 6 21:40:32 2018 +0000
Committer: Sandhya Sundaresan <sa...@apache.org>
Committed: Wed Jun 6 21:40:32 2018 +0000
----------------------------------------------------------------------
core/sql/cli/Context.cpp | 41 +++++++++++++++++++++---
core/sql/cli/SessionDefaults.cpp | 2 +-
core/sql/executor/ExExeUtil.h | 2 +-
core/sql/executor/ExExeUtilLoad.cpp | 2 +-
core/sql/exp/ExpLOB.cpp | 20 +++++++++++-
core/sql/runtimestats/ssmpipc.cpp | 55 +++++++++++++++++++++++++-------
6 files changed, 103 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/cli/Context.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Context.cpp b/core/sql/cli/Context.cpp
index ac09a9c..53d277e 100644
--- a/core/sql/cli/Context.cpp
+++ b/core/sql/cli/Context.cpp
@@ -3184,17 +3184,50 @@ Lng32 ContextCli::setLobLock(
)
{
CliGlobals *cliGlobals = getCliGlobals();
+ NABoolean releasingLock = FALSE;
if (cliGlobals->getStatsGlobals() == NULL)
{
(diagsArea_) << DgSqlCode(-EXE_RTS_NOT_STARTED);
return diagsArea_.mainSQLCODE();
}
ComDiagsArea *tempDiagsArea = &diagsArea_;
+ IpcServer *ssmpServer = NULL;
tempDiagsArea->clear();
-
- IpcServer *ssmpServer = ssmpManager_->getSsmpServer(exHeap(),
- cliGlobals->myNodeName(),
- cliGlobals->myCpu(), tempDiagsArea);
+ if (lobLockId[0] == '-')
+ releasingLock = TRUE;
+ // Get an ssmp node to talk to. Picking one based off of lobLockId should
+ // make it unique and avoid clash with another node that may be attempting
+ // to lock the same lob
+ if (!releasingLock)
+ {
+ Int32 nodeCount = 0;
+ Int32 rc = msg_mon_get_node_info(&nodeCount, 0, NULL);
+ Int32 targetNodeId = 0;
+ Int32 lockHash = 0;
+ char myNodeName[MAX_SEGMENT_NAME_LEN+1];
+ MS_Mon_Node_Info_Type nodeInfo;
+ for (int i = 0; i < LOB_LOCK_ID_SIZE; i++)
+ lockHash +=(unsigned char)lobLockId[i];
+ if (nodeCount)
+ targetNodeId = lockHash%nodeCount;
+ rc = msg_mon_get_node_info_detail(targetNodeId, &nodeInfo);
+ if (rc == 0)
+ strcpy(myNodeName, nodeInfo.node[0].node_name);
+ else
+ myNodeName[0] = '\0';
+
+ ssmpServer = ssmpManager_->getSsmpServer(exHeap(),
+ //cliGlobals->myNodeName(),
+ //cliGlobals->myCpu(),
+ myNodeName,
+ targetNodeId,
+ tempDiagsArea);
+ }
+ else
+ ssmpServer = ssmpManager_->getSsmpServer(exHeap(),
+ cliGlobals->myNodeName(),
+ cliGlobals->myCpu(),
+ tempDiagsArea);
if (ssmpServer == NULL)
return diagsArea_.mainSQLCODE();
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/cli/SessionDefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/SessionDefaults.cpp b/core/sql/cli/SessionDefaults.cpp
index 1e656bd..388e02f 100644
--- a/core/sql/cli/SessionDefaults.cpp
+++ b/core/sql/cli/SessionDefaults.cpp
@@ -792,7 +792,7 @@ static const AQRInfo::AQRErrorMap aqrErrorMap[] =
// locked row timeout
AQREntry( 8550, 73, 2, 0, 0, 0, "", 0, 0),
AQREntry( 8550, 78, 1, 60, 0, 0, "", 0, 0),
- AQREntry( 8558, 0 , 2, 30, 0, 0, "", 0, 0),
+ AQREntry( 8558, 0 , 2, 10, 0, 0, "", 0, 0),
AQREntry( 8551, 12, 1, 60, 0, 0, "", 0, 0),
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/executor/ExExeUtil.h
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtil.h b/core/sql/executor/ExExeUtil.h
index aec3ccb..ea69e5e 100644
--- a/core/sql/executor/ExExeUtil.h
+++ b/core/sql/executor/ExExeUtil.h
@@ -3083,7 +3083,7 @@ public:
ExLobStats lobStats_;
char statusString_[200];
fstream indata_;
- char lobLockId_[12];
+ char lobLockId_[LOB_LOCK_ID_SIZE];
ExLobGlobals *exLobGlobals_;
};
// -----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/executor/ExExeUtilLoad.cpp
----------------------------------------------------------------------
diff --git a/core/sql/executor/ExExeUtilLoad.cpp b/core/sql/executor/ExExeUtilLoad.cpp
index e562430..160a6bb 100644
--- a/core/sql/executor/ExExeUtilLoad.cpp
+++ b/core/sql/executor/ExExeUtilLoad.cpp
@@ -3632,7 +3632,7 @@ short ExExeUtilLobUpdateTcb::work()
{
retcode = SQL_EXEC_SetLobLock(lobLockId_);
}
- else if (found)
+ else if (found || retcode )
{
memset(lobLockId_,'\0',LOB_LOCK_ID_SIZE);
ExRaiseSqlError(getHeap(), &diagsArea_,
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/exp/ExpLOB.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpLOB.cpp b/core/sql/exp/ExpLOB.cpp
index 2ef8ae4..10b2bc1 100644
--- a/core/sql/exp/ExpLOB.cpp
+++ b/core/sql/exp/ExpLOB.cpp
@@ -1029,10 +1029,27 @@ ex_expr::exp_return_type ExpLOBinsert::eval(char *op_data[],
{
ExpLOBoper::genLobLockId(objectUID_,lobNum(),llid);
NABoolean found = FALSE;
- retcode = SQL_EXEC_CheckLobLock(llid, &found);
+ int trycount = 0;
+ while (trycount < 3)
+ {
+ retcode = SQL_EXEC_CheckLobLock(llid, &found);
+ if (found || retcode )
+ {
+ sleep(5);
+ trycount++;
+ }
+ else
+ trycount =3;
+ }
if (! retcode && !found)
{
retcode = SQL_EXEC_SetLobLock(llid);
+ if (retcode)
+ {
+ ExRaiseSqlError(h, diagsArea,
+ retcode);
+ return ex_expr::EXPR_ERROR;
+ }
}
else
{
@@ -1041,6 +1058,7 @@ ex_expr::exp_return_type ExpLOBinsert::eval(char *op_data[],
return ex_expr::EXPR_ERROR;
}
+
}
err = insertDesc(op_data, h, diagsArea);
if (err == ex_expr::EXPR_ERROR)
http://git-wip-us.apache.org/repos/asf/trafodion/blob/bf8d8d6c/core/sql/runtimestats/ssmpipc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/runtimestats/ssmpipc.cpp b/core/sql/runtimestats/ssmpipc.cpp
index 504ef76..e56c761 100755
--- a/core/sql/runtimestats/ssmpipc.cpp
+++ b/core/sql/runtimestats/ssmpipc.cpp
@@ -1625,6 +1625,9 @@ void SsmpNewIncomingConnectionStream::actOnLobLockReq(
IpcConnection *connection)
{
IpcMessageObjVersion msgVer = getNextObjVersion();
+ StatsGlobals *statsGlobals;
+ NABoolean releasingLock = FALSE;
+ CliGlobals *cliGlobals = GetCliGlobals();
ex_assert(msgVer <= CurrLobLockVersionNumber,
"Up-rev message received.");
LobLockRequest *llReq= new (getHeap()) LobLockRequest(getHeap());
@@ -1632,17 +1635,47 @@ void SsmpNewIncomingConnectionStream::actOnLobLockReq(
setHandle(llReq->getHandle());
ex_assert(!moreObjects(),"Unexpected objects following LobLockRequest");
clearAllObjects();
-// Forward request to all mxsscps.
- ssmpGlobals_->allocateServers();
- SscpClientMsgStream *sscpMsgStream = new (heap_)
- SscpClientMsgStream(heap_, getIpcEnv(), ssmpGlobals_, this);
- sscpMsgStream->setUsedToSendLLMsgs();
- ssmpGlobals_->addRecipients(sscpMsgStream);
- sscpMsgStream->clearAllObjects();
- *sscpMsgStream << *llReq;
- llReq->decrRefCount();
- sscpMsgStream->send(FALSE);
-
+ //check and set the lock in the local shared segment
+ statsGlobals = ssmpGlobals_->getStatsGlobals();
+ char *inLobLockId = NULL;
+ inLobLockId = llReq->getLobLockId();
+ if (inLobLockId[0] == '-') //we are releasing this lock. No need to check.
+ inLobLockId = NULL;
+ else
+ {
+ inLobLockId = &inLobLockId[1];
+ statsGlobals->checkLobLock(cliGlobals, inLobLockId);
+ }
+
+ if (inLobLockId)
+ {
+ //It's already set, don't propagate
+ if (sscpDiagsArea_== NULL)
+ sscpDiagsArea_ = ComDiagsArea::allocate(ssmpGlobals_->getHeap());
+ *sscpDiagsArea_<< DgSqlCode(-EXE_LOB_CONCURRENT_ACCESS_ERROR);
+ RmsGenericReply *reply = new(getHeap())
+ RmsGenericReply(getHeap());
+
+ *this << *reply;
+ *this << *sscpDiagsArea_;
+ this->clearSscpDiagsArea();
+ send(FALSE);
+ reply->decrRefCount();
+ }
+ else
+ {
+
+ // Forward request to all mxsscps.
+ ssmpGlobals_->allocateServers();
+ SscpClientMsgStream *sscpMsgStream = new (heap_)
+ SscpClientMsgStream(heap_, getIpcEnv(), ssmpGlobals_, this);
+ sscpMsgStream->setUsedToSendLLMsgs();
+ ssmpGlobals_->addRecipients(sscpMsgStream);
+ sscpMsgStream->clearAllObjects();
+ *sscpMsgStream << *llReq;
+ llReq->decrRefCount();
+ sscpMsgStream->send(FALSE);
+ }
// Reply to client when the msgs to mxsscp have all completed. The reply
// is made from the sscpMsgStream's callback.