Skip to content

session prune: the retained path removes files and the directory by name after validation #463

Closed

Description

@ElbertePlinio

Found in the council review for #453 (PR #465). The code is unchanged from main. PR #455 documents the rmdir window as a known limit.

removeRetainedDirectory in packages/core/src/session-retention.ts validates each retained file, then removes it with dir.unlinkChild(name), by name. A writer that replaces xvfb.log between the check and the unlink loses the replacement, and prune still reports the id. The coordination path already checks each file's identity before removal, through unlinkOwnedFile.

Both paths end with rmdirIfEmpty(root.resolve(id)), also by name. Suppose a concurrent prune removes the directory after the identity check, and a first permit caller that stalled past teardown recreates an empty directory with the same id. This rmdir then removes the new directory. The caller fails closed on its next step, so no data is lost and no input is delivered.

No legitimate writer touches a retained directory after teardown, so the file case needs a stray local process. POSIX has no rmdir by inode. One approach for the directory: rename it to a unique name in the sessions root, check the renamed entry's device and inode, and only then remove it.

  • Remove retained files only while their identity matches the validated one, as the coordination path does
  • Decide whether to close the rmdir window or keep it as a documented limit
  • Test a replacement before each removal
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions