Skip to content

fix: drop repodata gateway before indexing local channel on publish - #6364

Merged
Hofer-Julian merged 2 commits into
mainfrom
claude/charming-hawking-naw7q1
Jun 30, 2026
Merged

Hofer-Julian merged 2 commits into
mainfrom
claude/charming-hawking-naw7q1

Conversation

@wolfv

@wolfv wolfv commented Jun 15, 2026

Copy link
Copy Markdown
Member

pixi publish to a local/network filesystem channel could fail to index
with a Windows os error 1224 (ERROR_USER_MAPPED_FILE) when the target
channel was also a channel the workspace solved against during the build.

The repodata Gateway memory-maps the repodata.json files it reads. The
open mapping prevents the subsequent indexing step from overwriting that
file on Windows. Dropping the command dispatcher (and with it the gateway)
after the build phase releases the mappings before indexing runs.

Fixes #6362

`pixi publish` to a local/network filesystem channel could fail to index
with a Windows `os error 1224` (ERROR_USER_MAPPED_FILE) when the target
channel was also a channel the workspace solved against during the build.

The repodata `Gateway` memory-maps the `repodata.json` files it reads. The
open mapping prevents the subsequent indexing step from overwriting that
file on Windows. Dropping the command dispatcher (and with it the gateway)
after the build phase releases the mappings before indexing runs.

Fixes #6362
Comment thread crates/pixi_cli/src/publish.rs Outdated
Comment on lines +783 to +797
// Phase 1 is done with the command dispatcher. Drop it (and with it the
// repodata `Gateway`) before we start writing into the target channel.
//
// The gateway memory-maps the `repodata.json` files it reads while solving.
// When the publish target is a local channel that the workspace also solves
// against, the gateway holds an open mmap of that channel's `repodata.json`.
// On Windows, indexing then fails to overwrite it with `os error 1224`
// (ERROR_USER_MAPPED_FILE: "The requested operation cannot be performed on a
// file with a user-mapped section open."). Dropping the dispatcher releases
// those mappings so the subsequent `index_fs`/`index_s3` can rewrite the
// repodata. See https://github.com/prefix-dev/pixi/issues/6362.
//
// The gateway lives in two places inside the dispatcher (`data.gateway` and a
// clone in the compute engine's data store), both owned solely by this value,
// so this drop fully tears it down.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems a bit excessive

@baszalmstra

Copy link
Copy Markdown
Contributor

I think a much better fix would be: conda/rattler#2084

@baszalmstra

Copy link
Copy Markdown
Contributor

Actually since that is already in this should not be a problem? Can you ask clanker why this still happens?

@wolfv

wolfv commented Jun 15, 2026

Copy link
Copy Markdown
Member Author
  1. Wrong operation. The failure is a resize/truncate, not a delete. os error 1224 = ERROR_USER_MAPPED_FILE is raised by the Windows kernel for operations that change a file's size (SetEndOfFile, or opening with truncation) while any user-mapped section is open on it. This is a hard restriction — no share-mode flag can relax it. FILE_SHARE_DELETE only governs delete/rename, which return ERROR_SHARING_VIOLATION, a different error. So even with chore: improve error when protocol messages are invalid #2084 applied, truncating a mapped file still fails with 1224.

  2. The writer truncates in place via opendal, it doesn't atomic-replace. Note the error: Unexpected (temporary) at write, context: { service: fs, path: noarch/repodata.json }. That service: fs is opendal's filesystem backend, which rattler_index::index_fs writes through. It opens the existing repodata.json and truncates it in place rather than writing a temp file and renaming it over the target. #2084's FILE_SHARE_DELETE would only have helped a temp-file-plus-rename strategy — the in-place truncating write never benefits from it.

@wolfv

wolfv commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

I have a sister PR that addresses this issue using the OpenDAL atomic write functions: conda/rattler#2511

@wolfv

wolfv commented Jun 15, 2026

Copy link
Copy Markdown
Member Author

IMO we could still merge this. The other PR should also help.

@baszalmstra

Copy link
Copy Markdown
Contributor

Sure but as soon as we need the command dispatcher for something else and remove the drop it will still break. A proper solution, like the one you just merged in rattler will make this completely unnecessary.

@wolfv

wolfv commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

I'll close this for now.

@wolfv wolfv closed this Jun 30, 2026
@wolfv wolfv reopened this Jun 30, 2026
@wolfv

wolfv commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

I think it would still be useful to merge this for now. I think it makes sense to drop the gateway before reindexing ...

@Hofer-Julian
Hofer-Julian merged commit 483d2df into main Jun 30, 2026
38 checks passed
@Hofer-Julian
Hofer-Julian deleted the claude/charming-hawking-naw7q1 branch June 30, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pixi failing to index channel after publishing to channel

4 participants