Skip to content

Vine: Update file state only at task completion. - #4587

Open
dthain wants to merge 5 commits into
cooperative-computing-lab:masterfrom
dthain:vine-file-still-pending
Open

dthain wants to merge 5 commits into
cooperative-computing-lab:masterfrom
dthain:vine-file-still-pending

Conversation

@dthain

@dthain dthain commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

  • File state should only become VINE_FILE_STATE_AVAILABLE when checking downloading file outputs.
  • This addresses a subtle race condition when chaining together tasks with plain files.
  • Update commentary in several places to clarify understanding of file->state.

Merge Checklist

The following items must be completed before PRs can be merged.
Check these off to verify you have completed all steps.

  • make test Run local tests prior to pushing.
  • make format Format source code to comply with lint policies. Note that some lint errors can only be resolved manually (e.g., Python)
  • make lint Run lint on source code prior to pushing.
  • Manual Update: Update the manual to reflect user-visible changes.
  • Type Labels: Select a github label for the type: bugfix, enhancement, etc.
  • Product Labels: Select a github label for the product: TaskVine, Makeflow, etc.
  • PR RTM: Mark your PR as ready to merge.

…/downloading file outputs.

- This addresses a subtle race condition when chaining together tasks with plain files.
- Update commentary in several places to clarify understanding of file->state.
@dthain dthain added bug For modifications that fix a flaw in the code. TaskVine labels Nov 23, 2026
@dthain

dthain commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@btovar @JinZhou5042 @colinthomas-z80 this is a tricky one that may affect more than the immediate bug problem. Please take a close look and give me your thoughts on whether this fits our broader concepts around file handling. I think the philosophical change here is that while a cache-update creates a vine_file_replica right away, the vine_file isn't CREATED until we handle the task completion message either consider/fetch each of its outputs.

Comment thread taskvine/src/manager/vine_file.h Outdated
A file in the CREATED state does not necessarily have a replica yet.
However, a task that needs it can be scheduled, because a replica either exists
or can be created from an available source.
- A file is PENDING if the contents of the file are not available,

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.

These two cases as described here seem to overlap. Once says that the contents could be created, the other says that they will be created. What is the real difference?

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.

I have the same question too. I think the difference should be whether the producing task has succeeded, CREATED means it has and PENDING means it hasn't.

@dthain dthain Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm, the distinction is subtle but I think my explanation is not good enough yet.

Both files and replicas have state, but they mean different things.

The state of a file describes its logical existence.

  • A file that is PENDING does not exist anywhere yet, because it is the output of some task that has not yet run. The manager cannot materialize the file, except by scheduling the task that creates it. The metadata of this file (such as the size) are unknown, because it has never been created.
  • A file that is CREATED has the contents available such that the manager can deliver it to a task when scheduled. A FILE exists if its contents are stored at the manager. A TEMP if its contents are on a worker somewhere. A URL and a MINI_TASK are always in the CREATED state because they can be delivered on demand. The metadata of this file (such as the size) are known, because it has been "seen" in the wild.

However, the state of a file is orthogonal to the state of its replicas:

  • A normal FILE may be CREATED because it exists I the manager's filesystem, and yet not have any replicas on workers, because they simply haven't been transferred yet.
  • A TEMP file (with this patch) will briefly have a replica (when a cache-update is received) and yet still be in the PENDING state because we have not yet processed the completion of the corresponding task. Once we determine that the task succeeded and iterate over its outputs, we declare the file CREATED and available for use by other tasks.

Does that help?

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.

Yes, that makes a lot more sense to me.

A file that is CREATED has the contents available such that the manager can deliver it to a task when scheduled. A FILE exists if its contents are stored at the manager. A TEMP if its contents are on a worker somewhere

But in the fix a TEMP is CREATED not only when the contents are on a worker somewhere, but also when the producing task is marked as complete by the manager. So should it be that both FILE and TEMP is CREATED when the corresponding producing task is complete?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think you could make an argument in favor handling the replica file type in one place and the file type in the other place. But that sort of disparate handling makes me concerned for maintainability. I split them up so that cache-update is primarily about handling replica status, and vine_manager_get_output_files handles file contents and status.

Is there a substantial benefit to marking (only)TEMP files as immediately CREATED when the cache-update arrives?

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.

I think I'm still confused with:

A file that is CREATED has the contents available such that the manager can deliver it to a task when scheduled. A FILE exists if its contents are stored at the manager. A TEMP if its contents are on a worker somewhere.

What does exists mean? That is CREATED or it is a different thing. If a TEMP file was created but lost all of its replicas, does it go back to pending?

Created is tripping me for files. It makes sense for replicas? For files I would say AVAILABLE or PENDING?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I like PENDING -> AVAILABLE, let me take a crack at that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok with this terminology now?

if (f) {
/* We know it exists and how large it is now. */
f->state = VINE_FILE_STATE_CREATED;
/* We now know the size of the file. */

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.

How do we know the size of the file but it is not created? Do we need better names created vs pending? file met once vs never met? Is that the difference?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Indeed this is a little strange. If the file did not already exist, then the cache-update is the way that we discover the file size and other metadata.

@JinZhou5042

Copy link
Copy Markdown
Member

Let me know if my understanding is wrong. In the original implementation, a file is CREATED as soon as its cache-update arrives, so CREATED means that a replica exists on some worker. For VINE_TEMP that is enough because replicas are exactly the expected source. For VINE_FILE it is not, because a task reads VINE_FILE gets it only from the manager's local storage, which the manager only retrieves when it handles the producing task's completion, and the task requesting that file is abandoned because of input missing.

@colinthomas-z80

Copy link
Copy Markdown
Contributor

An alternative idea may be to keep the existing states and modify the task dispatch to allow a peer transfer from the worker it was created on before it exists on the manager.

If peer transfers are disabled or fail it will allow another cycle of the main loop which will likely download the file. This could accelerate workflows which are impeded by manager downloads.

@dthain

dthain commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Following up on our discussion from the lab meeting last week.
Is everyone ok with this change now?

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

Labels

bug For modifications that fix a flaw in the code. TaskVine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants