go uses the ent framework to connect to the database and reports error driver: bad connection

Enable multiple coroutines in the code. These coroutines are in the same transaction. These coroutines have enabled database operations. If multiple coroutines are read and written concurrently in the transaction, this error will be reported.
Solution: Extract all database operations in the coroutine and execute them in the main thread, so that the database read and write operations of the same transaction can be executed serially

Guess you like

Origin blog.csdn.net/qq_26356861/article/details/125081317