[PATCH] run-tests: lock uses of channels to avoid race condition

timeless timeless at gmail.com
Fri Jan 22 00:05:38 CST 2016


So, I've tried to fix this in the past.

(py)[timeless at gcc2-power8 tests]$ hg co 0b752757a0c4f30ac755389014e2af9d2e0b4a3f
104 files updated, 0 files merged, 19 files removed, 0 files unresolved
(py)[timeless at gcc2-power8 tests]$ hg import 10
applying 10
(py)[timeless at gcc2-power8 tests]$ hg log -vr .
changeset:   30637:dacb8cdff031
branch:      stable
tag:         tip
user:        Bryan O'Sullivan <bos at serpentine.com>
date:        Thu Jan 21 20:30:23 2016 -0800
files:       tests/run-tests.py
description:
run-tests: lock uses of channels to avoid race condition

When running multiple tests at once, there's a huge race condition
that, for me, is 100% reproducible.  Laurent's commit 0b752757a0c4
tries to address the same problem, but doesn't correctly fix it.

1. A KeyboardInterrupt is raised to the main thread.

2. "channels = []" is invoked at the end of "TestSuite.run".

3. The KeyboardInterrupt propagates to each thread running the local
   function "job", and an attempt is made to assign to
   "channels[channel]" based on the now-wrong understanding that
   "channels" is non-empty.

The result is that every thread raises an IndexError.

With this commit, every access to "channels" is protected by a
lock, and in the "job" threads, checked for non-emptiness.


(py)[timeless at gcc2-power8 tests]$ time ./run-tests.py -l -j120
..ss^C
Skipped test-convert-svn-move.t: missing feature: subversion python bindings
Skipped test-convert-svn-source.t: missing feature: subversion python bindings
# Ran 122 tests, 2 skipped, 0 warned, 0 failed.
INTERRUPTED: test-rebase-check-restore.t (after 1 seconds)
INTERRUPTED: test-obsolete-checkheads.t (after 1 seconds)
INTERRUPTED: test-gendoc.t (after 1 seconds)
INTERRUPTED: test-check-commit.t (after 1 seconds)
INTERRUPTED: test-merge-changedelete.t (after 1 seconds)
INTERRUPTED: test-check-py3-compat.t (after 1 seconds)
INTERRUPTED: test-check-code.t (after 1 seconds)
EINTERRUPTED: test-https.t (after 1 seconds)
EINTERRUPTED: test-getbundle.t (after 1 seconds)
EINTERRUPTED: test-hgweb-descend-empties.t (after 1 seconds)
EINTERRUPTED: test-treediscovery.t (after 1 seconds)
INTERRUPTED: test-acl.t (after 2 seconds)
INTERRUPTED: test-contrib-check-code.t (after 2 seconds)
^CINTERRUPTED: test-convert-cvs.t (after 2 seconds)
INTERRUPTED: test-encoding-textwrap.t (after 2 seconds)
INTERRUPTED: test-patchbomb.t (after 2 seconds)
^CINTERRUPTED: test-contrib-perf.t (after 2 seconds)
^C^CINTERRUPTED: test-hgweb-commands.t (after 2 seconds)
INTERRUPTED: test-rename-merge2.t (after 2 seconds)
INTERRUPTED: test-check-execute.t (after 2 seconds)
^CINTERRUPTED: test-bundle2-format.t (after 2 seconds)
^C^C^C^C^C^C^CINTERRUPTED: test-run-tests.t (after 3 seconds)
^C^C^C^C^C^C^C^C^C^C^C^C^CINTERRUPTED: test-merge-force.t (after 4 seconds)
^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^Z
[1]+  Stopped                 ./run-tests.py -l -j120

real    0m12.689s
user    0m0.000s
sys    0m0.000s
(py)[timeless at gcc2-power8 tests]$ fg
./run-tests.py -l -j120

The test-runner doesn't seem to die properly if you manage to get it
to not mess up channels.
I did something less correct to avoid crashing in channels, but it
yielded the same result.

I don't consider this progress, since I'd rather the test runner die
when I use ctrl-c than it give me slightly more correct output but not
die and require me to suspend and kill it.

On Thu, Jan 21, 2016 at 11:41 PM, Bryan O'Sullivan <bos at serpentine.com> wrote:
>
> On Thu, Jan 21, 2016 at 8:34 PM, Bryan O'Sullivan <bos at serpentine.com>
> wrote:
>>
>> run-tests: lock uses of channels to avoid race condition
>
>
> Forgot to flag this as [stable], which it is.
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list