redis-orm
redis-orm copied to clipboard
MySQL: orm should support context
background
In our daily development, we use the SQL operations together with some rpc functions . And, we pass the context between the rpc invocation , however, redis-orm do not accept this ctx within its SQL execution.
proposal
result, err := tx.tx.Exec(sql, args...)
if err != nil {
tx.err = err
}
we should provide a new method to pass the outside ctx into the Exec , perhaps it will be like :
result, err := tx.tx.ExecContext(ctx,sql, args...)
if err != nil {
tx.err = err
}
covered situation
- grpc: The invoker inspector client canceled(OR Timeout) the grpc request,and set the context,but the server side will continue the SQL operations .And once the invoker retries , it will receive some database error(i.e. the record lock error OR the dirty reads)
It is a good idea !
see #86
Fixed in #86