Commit bc27016
committed
š
Fixes the ``UNIQUE constraint failed: db_dbcomputer.label`` flake on
``tests-presto`` (#7347): the ``aiida_localhost`` fixture's Computer now
lives under a label suffixed with the pytest-xdist worker id
(``localhost-main`` outside xdist, ``localhost-gw0`` etc. inside), so
it never collides with a literal ``'localhost'`` Computer that another
code path has created in the same profile.
Mechanism. The fixture's lookup filters on four fields (``label``,
``hostname``, ``scheduler_type``, ``transport_type``); the
``Computer.label`` UNIQUE constraint is single-column. When ``verdi
presto`` or ``verdi devel launch-shell-job`` had already inserted a
``localhost`` Computer in the same profile, the four-field
``Computer.collection.get`` would miss it (mismatched fields), and the
fallback ``store()`` would trip the single-column UNIQUE on label.
Worker-suffixing the fixture's label removes the collision at the source
ā the fixture row simply lives under a different name from any
literal-label row that other code paths may create.
Note this also corrects a parallelism-correctness bug that predates the
flake: the fixture was written before xdist was a concern and assumed
exclusive use of "the" localhost row in the test profile. The literal
``'localhost'`` label remains the production contract for ``verdi
presto`` and ``verdi devel launch-shell-job`` and is left untouched.
Test usages that hardcoded ``orm.load_computer('localhost')`` to reach
the fixture-created computer are switched to depend on
``aiida_localhost`` directly.aiida_localhost: suffix label with xdist-worker id1 parent 6adc2b0 commit bc27016
3 files changed
Lines changed: 54 additions & 5 deletions
File tree
- src/aiida/tools/pytest_fixtures
- tests
- calculations
- tools/pytest_fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
14 | 29 | | |
15 | 30 | | |
16 | 31 | | |
| |||
269 | 284 | | |
270 | 285 | | |
271 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
272 | 293 | | |
273 | 294 | | |
274 | 295 | | |
275 | 296 | | |
276 | 297 | | |
277 | 298 | | |
278 | 299 | | |
279 | | - | |
| 300 | + | |
280 | 301 | | |
281 | 302 | | |
282 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
21 | 49 | | |
22 | 50 | | |
23 | 51 | | |
| |||
0 commit comments