Skip to content

CI Fix - Windows Tests Race Condition #6010

Description

@cmgoffena13

AI Notes

Failing Test

tests/lsp/test_reference_macro_find_all.py::test_multi_repo_macro_references

What's Wrong

The on-disk model cache is not written atomically. FileCache.put opens the cache file with "wb", which truncates it, then pickle/gzip writes the contents.

With xdist, two workers can share the same cache file. A reader can open the file after truncate and before the write finishes. pickle.load then fails with “Ran out of input”. In this run, silver.d never made it into the LSP map.

This is a cache race, not a bad assertion in the LSP test.

Possible Fix

In sqlmesh/utils/cache.py FileCache.put, stop writing the cache file in place ("wb" truncates it first).

  1. Write the gzip/pickle to a temp file in the same directory.
  2. os.replace that temp file onto the real cache path.

That way another pytest-xdist worker never reads a half-written models__d entry.

Optionally retry FileCache.get once if pickle hits EOF / “Ran out of input”, then load from SQL.

Don’t xfail the LSP test. The test is fine; the cache write is the bug.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions