Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysqlworker fixes #342

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions worker/mysqlworker/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func (adapter *mysqlAdapter) InitDB() (*sql.DB, error) {
err = errors.New("cannot use read-only conn " + curDs)
}
if is_writable {
calTrans.SetStatus(cal.TransOK) //Reset the URL status to success
break
}
}
Expand Down
20 changes: 15 additions & 5 deletions worker/shared/cmdprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ type CmdProcessor struct {
lastErr error
// the FNV hash of the SQL, for logging
sqlHash uint32
// corr_id for logging
m_corr_id string
// the name of the cal TXN
calSessionTxnName string
heartbeat bool
Expand Down Expand Up @@ -207,11 +209,18 @@ func (cp *CmdProcessor) ProcessCmd(ns *netstring.Netstring) error {
outloop:
switch ns.Cmd {
case common.CmdClientCalCorrelationID:
//
// @TODO parse out correlationid.
//
if cp.calSessionTxn != nil {
cp.calSessionTxn.SetCorrelationID("@todo")
if logger.GetLogger().V(logger.Verbose) {
logger.GetLogger().Log(logger.Verbose, "CmdClientCalCorrelationID:", string(ns.Payload), string(ns.Serialized))
}
cp.m_corr_id = "unset"
if len(string(ns.Payload)) > 0 {
splits := strings.Split(string(ns.Payload), "=")
if (len(splits) == 2) && (len(splits[1]) > 0) {
logger.GetLogger().Log(logger.Verbose, "splits:", len(splits), splits[0], splits[1])
cp.m_corr_id = splits[1]
} else {
logger.GetLogger().Log(logger.Warning, "CmdClientCalCorrelationID: Payload not in expected K=V format:", string(ns.Payload))
}
}
case common.CmdPrepare, common.CmdPrepareV2, common.CmdPrepareSpecial:
cp.dedicated = true
Expand All @@ -237,6 +246,7 @@ outloop:
cp.hasResult, startTrans = cp.sqlParser.Parse(sqlQuery)
if cp.calSessionTxn == nil {
cp.calSessionTxn = cal.NewCalTransaction(cal.TransTypeAPI, cp.calSessionTxnName, cal.TransOK, "", cal.DefaultTGName)
cp.calSessionTxn.AddDataStr("corrid", cp.m_corr_id)
}
cp.calSessionTxn.SendSQLData(string(ns.Payload))
cp.sqlHash = utility.GetSQLHash(string(ns.Payload))
Expand Down
Loading