[PATCH] localrepo: prevent leak of transaction object (issue4258)

Durham Goode durham at fb.com
Wed May 21 20:36:20 CDT 2014


On 5/21/14, 6:02 PM, "Gregory Szorc" <gregory.szorc at gmail.com> wrote:

># HG changeset patch
># User Gregory Szorc <gregory.szorc at gmail.com>
># Date 1400720555 25200
>#      Wed May 21 18:02:35 2014 -0700
># Node ID 86829970c3fbf3134560a143f74444066d2e9623
># Parent  9fb6f328576ac4e38f4e5071c4d669a6ceb3a76e
>localrepo: prevent leak of transaction object (issue4258)
>
>The onclose() closure added in cd443c7589cc held a regular reference to
>the transaction object. This was causing the transaction to not gc and
>a leak to occur.
>
>The closure now holds a reference to the weakref instance and the leak
>goes away.
>
>diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
>--- a/mercurial/localrepo.py
>+++ b/mercurial/localrepo.py
>@@ -860,9 +860,9 @@ class localrepository(object):
>                 _("abandoned transaction found"),
>                 hint=_("run 'hg recover' to clean up transaction"))
> 
>         def onclose():
>-            self.store.write(tr)
>+            self.store.write(self._transref())
> 
>         self._writejournal(desc)
>         renames = [(vfs, x, undoname(x)) for vfs, x in
>self._journalfiles()]
>         rp = report and report or self.ui.warn

I’m not familiar with the weak reference stuff in transactions, but if the
tests pass, this looks good to me.  Should probably be queued for STABLE
though.

Thanks for fixing this.



More information about the Mercurial-devel mailing list