Skip to content

Don't dedupe span metadata by id() (fix flaky test_collections_metadata)#9316

Merged
crusaderky merged 2 commits into
dask:mainfrom
crusaderky:test_collection_metadata
Jul 9, 2026
Merged

Don't dedupe span metadata by id() (fix flaky test_collections_metadata)#9316
crusaderky merged 2 commits into
dask:mainfrom
crusaderky:test_collection_metadata

Conversation

@crusaderky

@crusaderky crusaderky commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Span.add_metadata used a class-level id-based de-duplication system that was tracking the id of already seen metadata. However, id is volatile and can be reused by the CPython interpreter as soon as the original object with that id is dereferenced. This caused legitimate new metadata to be occasionally dropped.
This deduplication also grew unboundedly over the lifetime of the scheduler.

The only deduplication actually needed is within a single observe_tasks call, where all tasks of one graph submission share the same metadata object.

@crusaderky crusaderky added flaky test Intermittent failures on CI. tests Unit tests and/or continuous integration labels Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    19 files   -     21      19 suites   - 21   16h 34m 20s ⏱️ + 1h 33m 58s
 5 000 tests +   846   5 000 ✅ +1 025       0 💤  -   178  0 ❌  - 1 
95 000 runs  +14 159  85 000 ✅ +8 397  10 000 💤 +5 763  0 ❌  - 1 

Results for commit 6fa439b. ± Comparison against base commit ace5560.

This pull request removes 4154 and adds 5000 tests. Note that renamed tests count towards both.
distributed.cli.tests.test_dask_scheduler ‑ test_dashboard
distributed.cli.tests.test_dask_scheduler ‑ test_dashboard_allowlist
distributed.cli.tests.test_dask_scheduler ‑ test_dashboard_non_standard_ports
distributed.cli.tests.test_dask_scheduler ‑ test_dashboard_port_zero
distributed.cli.tests.test_dask_scheduler ‑ test_defaults
distributed.cli.tests.test_dask_scheduler ‑ test_hostport
distributed.cli.tests.test_dask_scheduler ‑ test_idle_timeout
distributed.cli.tests.test_dask_scheduler ‑ test_interface
distributed.cli.tests.test_dask_scheduler ‑ test_multiple_protocols
distributed.cli.tests.test_dask_scheduler ‑ test_multiple_workers
…
distributed.tests.test_spans ‑ test_collections_metadata[1-5000]
distributed.tests.test_spans ‑ test_collections_metadata[10-5000]
distributed.tests.test_spans ‑ test_collections_metadata[100-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1000-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1001-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1002-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1003-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1004-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1005-5000]
distributed.tests.test_spans ‑ test_collections_metadata[1006-5000]
…

♻️ This comment has been updated with latest results.

@crusaderky crusaderky force-pushed the test_collection_metadata branch 2 times, most recently from d964072 to 354ec06 Compare July 2, 2026 14:49
@crusaderky crusaderky mentioned this pull request Jul 3, 2026
4 tasks
@crusaderky crusaderky changed the title Fix flaky test_collection_metadata [Unsupervised AI] Fix flaky test_collection_metadata Jul 9, 2026
Span.add_metadata deduplicated incoming metadata via a class-level set of
id(metadata) values that was never pruned. Since CPython recycles the id of
garbage-collected objects, the metadata of a new graph submission could
collide with the id of a previous, dead metadata dict and be silently
dropped, leaving Span.metadata as None. The set also grew unboundedly over
the lifetime of the scheduler.

The only deduplication actually needed is within a single observe_tasks
call, where all tasks of one graph submission share the same metadata
object. Do that with a local set instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@crusaderky crusaderky force-pushed the test_collection_metadata branch from 6fa439b to 9f6efcb Compare July 9, 2026 12:18
@crusaderky crusaderky changed the title [Unsupervised AI] Fix flaky test_collection_metadata [unsupervised AI] Fix flaky test_collections_metadata: don't dedupe span metadata by id() Jul 9, 2026
@crusaderky crusaderky changed the title [unsupervised AI] Fix flaky test_collections_metadata: don't dedupe span metadata by id() Don't dedupe span metadata by id() (fix flaky `test_collections_metadata: Jul 9, 2026
@crusaderky crusaderky changed the title Don't dedupe span metadata by id() (fix flaky `test_collections_metadata: Don't dedupe span metadata by id() (fix flaky test_collections_metadata) Jul 9, 2026
@crusaderky crusaderky marked this pull request as ready for review July 9, 2026 13:46
@crusaderky crusaderky requested a review from fjetter as a code owner July 9, 2026 13:46
@crusaderky crusaderky added diagnostics p3 Affects a small number of users or is largely cosmetic scheduler and removed tests Unit tests and/or continuous integration labels Jul 9, 2026
@crusaderky crusaderky merged commit 4ecd5f0 into dask:main Jul 9, 2026
46 of 48 checks passed
@crusaderky crusaderky deleted the test_collection_metadata branch July 9, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diagnostics flaky test Intermittent failures on CI. p3 Affects a small number of users or is largely cosmetic scheduler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant