MCPcopy
hub / github.com/radondb/radon / executeWithTimeout

Method executeWithTimeout

src/proxy/execute.go:129–164  ·  view source on GitHub ↗

ExecuteNormal used to execute non-2pc querys to shards with timeout limits. timeout: 0x01. if timeout <= 0, no limits. 0x02. if timeout > 0, the query will be interrupted if the timeout(in millisecond) is exceeded.

(session *driver.Session, database string, query string, node sqlparser.Statement, timeout int)

Source from the content-addressed store, hash-verified

127// 0x01. if timeout <= 0, no limits.
128// 0x02. if timeout > 0, the query will be interrupted if the timeout(in millisecond) is exceeded.
129func (spanner *Spanner) executeWithTimeout(session *driver.Session, database string, query string, node sqlparser.Statement, timeout int) (*sqltypes.Result, error) {
130 log := spanner.log
131 conf := spanner.conf
132 router := spanner.router
133 scatter := spanner.scatter
134 sessions := spanner.sessions
135
136 // transaction.
137 txn, err := scatter.CreateTransaction()
138 if err != nil {
139 log.Error("spanner.txn.create.error:[%v]", err)
140 return nil, err
141 }
142 defer txn.Finish()
143
144 // txn limits.
145 txn.SetTimeout(timeout)
146 txn.SetMaxResult(conf.Proxy.MaxResultSize)
147 txn.SetMaxJoinRows(conf.Proxy.MaxJoinRows)
148 txn.SetIsExecOnRep(isExecOnRep(conf.Proxy.LoadBalance, node))
149
150 // binding.
151 sessions.TxnBinding(session, txn, node, query)
152 defer sessions.TxnUnBinding(session)
153
154 plans, err := optimizer.NewSimpleOptimizer(log, database, query, node, router).BuildPlanTree()
155 if err != nil {
156 return nil, err
157 }
158 executors := executor.NewTree(log, plans, txn)
159 qr, err := executors.Execute()
160 if err != nil {
161 return nil, err
162 }
163 return qr, nil
164}
165
166// ExecuteStreamFetch used to execute a stream fetch query.
167func (spanner *Spanner) ExecuteStreamFetch(session *driver.Session, database string, query string, node sqlparser.Statement, callback func(qr *sqltypes.Result) error) error {

Callers 2

ExecuteNormalMethod · 0.95
ExecuteDDLMethod · 0.95

Calls 11

ExecuteMethod · 0.95
isExecOnRepFunction · 0.85
CreateTransactionMethod · 0.80
TxnBindingMethod · 0.80
TxnUnBindingMethod · 0.80
FinishMethod · 0.65
SetTimeoutMethod · 0.65
SetMaxResultMethod · 0.65
SetMaxJoinRowsMethod · 0.65
SetIsExecOnRepMethod · 0.65
BuildPlanTreeMethod · 0.65

Tested by

no test coverage detected