Skip to content

posix: a crash during a synchronous upload leaves the file processing forever #1002

Open

Description

@butonic

On posix a synchronous upload still goes mark -> commit -> unmark: PrepareUpload switches the node and marks it processing:<session id>, CommitUpload writes the bytes and only then MarkProcessing(false) removes the mark (

func (c *coordinator) commit(ctx context.Context, session Session) (*provider.ResourceInfo, error) {
ref := session.Reference()
f, err := os.Open(session.BinPath())
if err != nil {
return nil, err
}
// The verdict rides along with the bytes, so a committed blob always carries
// the one it was cleared under. Empty on the inline path, which never scans.
scanResult, scanDate := session.ScanData()
// CommitUpload does not own the body; we opened it, so we close it. The path
// lets a driver that can move the staged file into place skip the copy.
err = c.fs.CommitUpload(ctx, &ref, session.ID(), storage.UploadSource{
Body: f,
Path: session.BinPath(),
Length: session.Size(),
ScanResult: scanResult,
ScanDate: scanDate,
})
f.Close()
if err != nil {
return nil, err
}
// Not unmarkProcessing: the commit succeeded, so a missing node is unexpected.
if err := c.fs.MarkProcessing(ctx, &ref, false, session.ID()); err != nil {
). If the process dies in between, nothing ever removes the mark, because nothing postprocesses synchronous uploads. Downloads answer 425 and deletes fail with TooEarly ... forever.

#976 fixed this for decomposed and decomposeds3 by storing the blob before the node points to it, and by healing stuck nodes on download. #1001 brings the same to the coordinator. Both skip posix on purpose: the posix blobstore writes to the node's live path, so there is no "blob first", and the recovery bails out early:

// https://github.com/opencloud-eu/reva/blob/f134c0d9f72f362b25389a9fc37b3d13c52a841f/pkg/storage/pkg/decomposedfs/recover.go#L35
if !fs.separateBlobs || fs.o.AsyncFileUploads {
	// processing markers are expected here, postprocessing removes them
	return false
}

The bytes are not lost: the coordinator session (<upload dir>/<id> and <id>.info) survives the crash. So posix could heal the node from the session the same way, on download or when the coordinator starts:

  • if the node is processing:<id>, its blob id is <id> and the session is old enough, commit the staged bytes and remove the mark
  • if the session is gone, restore the snapshot revision PrepareUpload took, or at least drop the mark so the file can be deleted

The same is true on main, where the legacy upload path also only stores the blob first for separate blobstores.

related: opencloud-eu/opencloud#3879 (same symptom after a crash, but for async postprocessing), opencloud-eu/opencloud#3870

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions