Consider implementing SessionResetter
or Validator
#261
Replies: 1 comment 3 replies
-
This will have an impact on performance, though: On your suggestion: I don't see how On goals: Ideally So, thoughts: I think the developer messing up and Errors the developer doesn't control, like cancellation, can make sense to flag, though. Can you demonstrate a reaching a bad state using only structured transactions, closing rows and transactions, but then cancellation or something out of control happens? That'd make sense to try to fix. But note that:
If, OTOH, the idea is to make stuff bulletproof, the only way is to not really pool connections, and basically “reopen” them everytime. But this is costly, even if I invented an API to reuse wazero. |
Beta Was this translation helpful? Give feedback.
-
The
database/sql
driver docs say:Implementing
SessionResetter
and/orValidator
would probably be a good idea.One thing to look for:
!GetAutocommit()
.Another thing to look for:
GetAutocommit() && TxnState() != TXN_NONE
.(As I showed in another discussion, the second is possible when a context is cancelled during the stepping of an auto-commit statement.)
So what to do if one of those is found?
In the first case,
SessionResetter
could try to roll back the transaction?In the second case,
Validator
could signal that the connection was invalid?You might have better ideas.
The main thing, really, is to prevent one problem from quietly causing other problems.
Beta Was this translation helpful? Give feedback.
All reactions