mysqljs/mysql

Auto-rollback of released connections without transaction commit

Open

#1.116 aberto em 3 de jun. de 2015

Ver no GitHub
 (8 comments) (0 reactions) (0 assignees)JavaScript (2.502 forks)batch import
featurehelp wanted

Métricas do repositório

Stars
 (18.137 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

When using a connection pool, releasing a connection should have a similar effect to ending a connection (aside from simply keeping the connection open). For starters, it would be extremely convenient to know if a connection has started a transaction (i.e. a boolean flag for isInTransaction) which would provide the following benefits:

  1. Passing an existing connection to child functions allows the child functions to operate independently and decide when/whether transactions need to be started (ability to shorten transaction lifecycles to reduce potential deadlocks) vs. managing this in parent code.
  2. If connections are released without making a call to "Connection.commit", they should really auto-rollback the transaction (just like a call to connection.end would do). This ensures that when the connection is re-used, the true effect is that the connection operates like a new connection (rather than having strange side-effects where existing transactions might cause deadlock).

Guia do colaborador