Skip to content

This PR fixes an intermittent race condition where concurrent workspace_file resource creations would collide when automatically creating the target parent directory via client.Workspace.Mkdirs.#3

Open
gustavo89587 wants to merge 1 commit into
nubank:mainfrom
gustavo89587:fix/workspace-concurrent-mkdir
Open

This PR fixes an intermittent race condition where concurrent workspace_file resource creations would collide when automatically creating the target parent directory via client.Workspace.Mkdirs.#3
gustavo89587 wants to merge 1 commit into
nubank:mainfrom
gustavo89587:fix/workspace-concurrent-mkdir

Conversation

@gustavo89587

Copy link
Copy Markdown

Changes

  • Wrapped client.Workspace.Mkdirs execution to check for parallel creation signals.
  • Suppressed RESOURCE_ALREADY_EXISTS and ALREADY_EXISTS transient structural API responses, preventing unexpected failure when another concurrent thread creates the parent folder fractionally faster.

@gustavo89587

gustavo89587 commented Jun 3, 2026

Copy link
Copy Markdown
Author

The collision of concurrent threads in the client.Workspace.Mkdirs method stems from the lack of atomicity in the upstream endpoint of the Databricks API during the implicit creation of non-existent parent directory paths.

The proposed encapsulation exclusively intercepts transient structured error responses (RESOURCE_ALREADY_EXISTS) triggered when a thread T2 attempts fractional millisecond allocation after T1 exposes the node in the file system, simulating native idempotency behavior (mkdir -p).

The selective suppression of infrastructure errors prevents spurious failures in Terraform's massively parallel provisioning without altering the provider's abstract dependency graph. If upstream validation prefers handling via local mutex or exponential backoff in the gRPC/HTTP transport client layer to avoid API noise, please indicate the concurrency pattern accepted in your enterprise design.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant