writeText

fun writeText(text: String, maxRetries: Int = DEFAULT_MAX_RETRIES, initialDelayMs: Long = DEFAULT_INITIAL_DELAY_MS)

Writes text to this path with automatic retry on transient I/O failures.

On GCS-fuse mounts, Path.writeText() can fail with "Stale file handle" (ESTALE) during the close() call, which triggers the actual GCS upload. This happens when:

  • Multiple pods concurrently write to different subdirectories of the same GCS-fuse mount, causing metadata/generation conflicts on shared parent directory objects in GCS.

  • The GCS-fuse sidecar experiences transient memory pressure.

  • Stat cache serves stale generation numbers.

Since the error is transient, retrying after a short delay reliably resolves it.

Parameters

maxRetries

Maximum number of retry attempts (default: WriteWithRetryConstants.DEFAULT_MAX_RETRIES).

initialDelayMs

Initial delay before the first retry in milliseconds (default: WriteWithRetryConstants.DEFAULT_INITIAL_DELAY_MS). Each subsequent retry doubles the delay (exponential backoff).

Throws

if all retry attempts are exhausted.