Skip to content

Race condition writing same file dest on client #1581

@maert

Description

@maert

Problem

When two outputs: files structs have the same dest path there is a race condition and/or partial file truncation issue that means the plan is not idempotent. Repeatedly calling dagger --europa up followed by cat ./test in the example below will give different outputs. The order of the contents strings as well as --no-cache options seem to possibly affect the outputs as well. The export order of the files (test -> test2 versus test2 -> test below) seems to be consistent across the outputs.

package main

import "dagger.io/dagger"

dagger.#Plan & {
        outputs: {
                files: {
                        test: {
                                dest: "./test"
                                contents: "kale\n"
                        }
                        test2: {
                                dest: "./test"
                                contents: "carrots\n"
                        }
                }
        }
}

Test script:

#!/bin/bash

while true
do 
        dagger --europa  up
	#dagger --europa  --no-cache up
	cat ./test
	sleep 1;
done

Output:

[✔] outputs.files.test                                                                                                                                     0.0s
[✔] outputs.files.test2                                                                                                                                    0.0s
carrots
[✔] outputs.files.test2                                                                                                                                    0.0s
[✔] outputs.files.test                                                                                                                                     0.0s
kale
ts
[✔] outputs.files.test2                                                                                                                                    0.0s
[✔] outputs.files.test                                                                                                                                     0.0s
kale
[✔] outputs.files.test                                                                                                                                     0.0s
[✔] outputs.files.test2                                                                                                                                    0.0s
carrots
[✔] outputs.files.test2                                                                                                                                    0.0s
[✔] outputs.files.test                                                                                                                                     0.0s
kale
ts
[✔] outputs.files.test                                                                                                                                     0.0s
[✔] outputs.files.test2                                                                                                                                    0.0s
carrots

Solution

Depends on desired behavior, but I would have expected that two output file structs with the same dest and different contents would not be allowed and would throw an error.

Related

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions