Skip to content

Idea storage atomic write retries on PermissionError can hang #142

Open

Description

@edwardevs

Idea storage atomic write retries on PermissionError can hang

Severity: Medium
File: backend/app/storage/idea_storage.py:80

The _write_json_atomic function retries os.replace() up to 5 times on PermissionError with increasing delays. If the permission issue is permanent (e.g., read-only filesystem, incorrect ownership), the function sleeps for up to 0.75 seconds total before raising the error.

last_error: Optional[OSError] = None
for attempt in range(5):
    try:
        os.replace(temp_path, path)
        return
    except PermissionError as exc:
        last_error = exc
        if attempt == 4:
            break
        time.sleep(0.05 * (attempt + 1))
if last_error:
    raise last_error

Why it matters

In environments with persistent permission issues (e.g., Docker volumes, network mounts), every write operation adds 0.75 seconds of latency. The retry logic assumes transient locks, not permanent permission errors.

Activity

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