Skip to content

Regression with parallel tests on 2.7.3 and 2.8 #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xavfernandez opened this issue Sep 29, 2015 · 22 comments · Fixed by pypa/pip#3863
Closed

Regression with parallel tests on 2.7.3 and 2.8 #1083

xavfernandez opened this issue Sep 29, 2015 · 22 comments · Fixed by pypa/pip#3863
Assignees
Labels
plugin: xdist related to the xdist external plugin type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog type: bug problem that needs to be addressed

Comments

@xavfernandez
Copy link

Hello,
Some tests in pip test suite started failing with latest pytest releases:

@RonnyPfannschmidt RonnyPfannschmidt added type: bug problem that needs to be addressed plugin: xdist related to the xdist external plugin type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog labels Sep 29, 2015
@RonnyPfannschmidt RonnyPfannschmidt added this to the 2.8.2 milestone Sep 29, 2015
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Sep 29, 2015
xavfernandez added a commit to pypa/pip that referenced this issue Sep 29, 2015
@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8.2, 2.8.3 Oct 10, 2015
@nicoddemus nicoddemus modified the milestones: 2.8.3, 2.8.4 Nov 23, 2015
@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8.4, 2.8.5 Dec 6, 2015
@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8.5, 2.8.6 Dec 14, 2015
@xavfernandez
Copy link
Author

@RonnyPfannschmidt
Copy link
Member

hmm, indeed - i suspect this bug has been lingering longer, the structural change just makes it trigger more easily

@RonnyPfannschmidt
Copy link
Member

due to race conditions it seems, that the lockfile creation and the folder creation can intersect badly now, since it got a lot faster - i propose switching to a datetime+pid based folder name in order to reduce the likelihood of collisions

@nicoddemus opinions?

i'd suggest a folder name like 2016-01-04+15:46:33+1337 concatenating date, time and pid

@nicoddemus
Copy link
Member

i propose switching to a datetime+pid based folder name in order to reduce the likelihood of collisions

Which folder exactly do you mean @RonnyPfannschmidt? For example, here's what Travis is creating:

 /tmp/pytest-of-travis/pytest-1/popen-gw0/<test-name>

@xavfernandez
Copy link
Author

Any new idea ? :)

@nicoddemus
Copy link
Member

@RonnyPfannschmidt did you notice my question above? 😁

@xavfernandez
Copy link
Author

Any advancement ?
I'd like pip to keep on track with pytest 😿

@RonnyPfannschmidt
Copy link
Member

i can put a focus on it next week, this has been delayed due to unrelated personal life events

@xavfernandez
Copy link
Author

Any news ? 😿

@xavfernandez
Copy link
Author

Gentle ping, I'd rather not have pip indefinitely stranded on pytest==2.7.2 :-/

@RonnyPfannschmidt
Copy link
Member

atm i cant promise anything wrt getting at it soonish

@nicoddemus
Copy link
Member

@RonnyPfannschmidt could please you explain in more detail why do you think there is a race condition with the lock creation? I ask because looking at make_numbered_dir, the directory creation should avoid any race condition:

            try:
                udir = rootdir.mkdir(prefix + str(maxnum+1))
            except py.error.EEXIST:
                # race condition: another thread/process created the dir
                # in the meantime.  Try counting again
                if lastmax == maxnum:
                    raise
                lastmax = maxnum
                continue

IIUC, the lock file only exists so a directory in use won't be deleted by a new py.test session, but on Travis we only ever have one py.test session active at once (we create a temp directory for each session, with each slave reusing it).

Also, the original change only changed the tmp root directory and I suspect Travis's VMs contains a very small number of files in /tmp, so I don't see how that could affect the outcome of those tests.

Any hints on what's on your mind about the problem might be helpful. 😁

@nicoddemus
Copy link
Member

@RonnyPfannschmidt any further thoughts?

Either way, we really should tackle and solve this once and for all in the upcoming pytest sprint, in a couple of weeks.

@RonnyPfannschmidt
Copy link
Member

after some more investigation it seems like the tmpdir initialization/re-initialization at slave startup happens multiple times, once with the xdist configuration, once without

@RonnyPfannschmidt
Copy link
Member

this is related to #1618

nicoddemus added a commit to nicoddemus/pip that referenced this issue Jul 22, 2016
Re-using the built-in tmpdir fixture fixes pytest-dev/pytest#1083

Also with latest pytest there's no need to use --assert=plain on py35 anymore

Fixes pypa#3699
Fixes pytest-dev/pytest#1083
@nicoddemus nicoddemus removed this from the 2.8.6 milestone Jul 22, 2016
@nicoddemus
Copy link
Member

Opened pypa/pip#3863 which fixes this problem, although I couldn't identify why the original code did not work in the first place.

@RonnyPfannschmidt
Copy link
Member

my current impression is that the initialization of the tmpdir handler on a remote pytest is incorrect and happens twice due to the option application happening after the pytest initialization instead of before

@xavfernandez
Copy link
Author

Well, it's a good news that pip can now use the latest pytest.
But I'm uncomfortable with the fact we don't now why :-/

I guess you've already checked similar logs (PYTEST_DEBUG = 1) but I've recreated a branch to have more infos on the failure: https://travis-ci.org/pypa/pip/jobs/146602684

@nicoddemus
Copy link
Member

@xavfernandez agreed, @RonnyPfannschmidt has hunch that the problem might be regarding how options (specially basetemp) is forwarded and handled at the slaves, see #1743.

@RonnyPfannschmidt
Copy link
Member

@xavfernandez did some tests showing that my hunch was wrong

@nicoddemus
Copy link
Member

@RonnyPfannschmidt I was thinking, while #1743 makes sense, that wouldn't explain why their old tmpdir implementation did not work, after all it was correctly using config._tmpdir_factory (see my PR), which is also used by pytest's own tmpdir.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus yes, ever since @xavfernandez demonstrated that the issue is in fact not related to that, i do wonder what is the actual cause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: xdist related to the xdist external plugin type: backward compatibility might present some backward compatibility issues which should be carefully noted in the changelog type: bug problem that needs to be addressed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants