redis-orm icon indicating copy to clipboard operation
redis-orm copied to clipboard

MySQL: orm should support context

Open scbizu opened this issue 8 years ago • 3 comments

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)

scbizu avatar Sep 30 '18 06:09 scbizu

It is a good idea !

54niyu avatar Sep 30 '18 06:09 54niyu

see #86

scbizu avatar Dec 06 '18 14:12 scbizu

Fixed in #86

scbizu avatar Mar 21 '19 11:03 scbizu