Re: What's the meaning of mysqli.rollback_on_cached_plink?
| From: | Johannes Schlüter | Date: | Tue, 24 Apr 2018 16:57:51 +0000 |
| Subject: | Re: What's the meaning of mysqli.rollback_on_cached_plink? | ||
| References: | 1 2 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969386933@lists.php.net to get a copy of this message | ||
Hi,
Kalle thanks for CCing, I'm indeed not on the docs list.
On Di, 2018-04-24 at 18:24 +0200, Kalle Sommer Nielsen wrote:
> 2018-04-24 18:05 GMT+02:00 Christoph M. Becker <cmbecker69@gmx.de>:
> >
> > Hi everybody!
> >
> > While updating the German translation,
cool!
> > I've stumbled upon
> > mysqli.rollback_on_cached_plink, which is documented[1] as:
> >
> > >
> > > Used for rollbacking connections put back into the persistent
> > > connection pool.
> > The migration guide[2] uses a slightly different wording:
> >
> > >
> > > […] to rollback connections put back into the persistent
> > > connection
> > > pool.
> > Frankly, I don't understand what that's supposed to mean (are these
> > even
> > proper English sentences?)
> >
> > The respective commit[3] message isn't more helpful, but from
> > reading
> > the actual commit, it seems that:
> >
> > If mysqli.rollback_on_cached_plink is enabled, and a persistent
> > connection is closed, it is attempted to rollback any pending
> > transactions, and if that succeeds, the persistent connection is
> > actually closed, instead of putting it back into the persistent
> > connection pool. If mysqli.rollback_on_cached_plink is disabled,
> > no
> > attempt to rollback or close the connection is made, and it is put
> > back
> > into the persistent connection pool.
> >
> > Is that correct? Any clarification is welcome!
> >
Yes that is correct.
http://git.php.net/?p=php-src.git;a=blob;f=ext/mysqli/mysqli_api.c;h=2b
cbe2846ebe495e00c398bfa5786e6f1741749b;hb=HEAD#l694
is the relevant code.
So when the connection is "closed" (be it explicetily by using
mysqli_close() or implicitly by scope/scrpt end) and you are using
persitent connections the connection is put back in the pool of
persistent connections available.
If this setting is set also a rollback is initiated to rollback all
transactions.
Interestingly mysqlnd also does a "change_user" call when taking
connections out of the persistent connection pool which, among other
things, will also does a rollback of outstanding transactions.
In effect I believe the only effect is to decide /when/ the rollback
happens - at "close" time or when taking the connection out of the pool
for a new connections.
johannes