Skip to content

Fix race condition when creating s3 buckets#594

Merged
ktrops merged 3 commits into
indeedeng:mainfrom
something-something-something:fix-race-condition-when-creating-bucket
Oct 29, 2025
Merged

Fix race condition when creating s3 buckets#594
ktrops merged 3 commits into
indeedeng:mainfrom
something-something-something:fix-race-condition-when-creating-bucket

Conversation

@something-something-something
Copy link
Copy Markdown
Contributor

@something-something-something something-something-something commented Oct 15, 2025

Description

Explanation of bug:
When trying to run the lite docker container using

docker run -p 8801:8801 -p 7233:7233 -p 8233:8233 -e AUTO_FIX_WORKER_URL=host.docker.internal --add-host host.docker.internal:host-gateway -it iworkflowio/iwf-server-lite:latest

It exits and I get this error

2025/10/15 00:43:46 bucket created successfully: iwf-test-bucket
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /                         --> github.com/indeedeng/iwf/service/api.(*handler).index-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/start    --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowStart-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/waitForStateCompletion --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowWaitForStateCompletion-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/signal   --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowSignal-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/publishToInternalChannel --> github.com/indeedeng/iwf/service/api.(*handler).apiV1PublishToInternalChannel-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/dataobjects/get --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowGetDataAttributes-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/dataobjects/set --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowSetDataAttributes-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/searchattributes/get --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowGetSearchAttributes-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/searchattributes/set --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowSetSearchAttributes-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/get      --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowGet-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/getWithWait --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowGetWithWait-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/search   --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowSearch-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/reset    --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowReset-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/stop     --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowStop-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/timer/skip --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowSkipTimer-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/internal/dump --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowInternalDump-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/config/update --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowConfigUpdate-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/triggerContinueAsNew --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowTriggerContinueAsNew-fm (3 handlers)
[GIN-debug] POST   /api/v1/workflow/rpc      --> github.com/indeedeng/iwf/service/api.(*handler).apiV1WorkflowRpc-fm (3 handlers)
[GIN-debug] GET    /info/healthcheck         --> github.com/indeedeng/iwf/service/api.(*handler).infoHealthCheck-fm (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on :8801
2025/10/15 00:43:46 failed to create bucket{{error 26 0  0xc000a86c30}}

Note how both 2025/10/15 00:43:46 bucket created successfully: iwf-test-bucket and 2025/10/15 00:43:46 failed to create bucket{{error 26 0 0xc000a86c30}} are loged

from what I can tell this ends up invoking createBucketIfNotExists twice (for interpreter and api) in parallel. Both detect that the bucket is missing one creates the bucket and the other fails to create the bucket because it already exists.

for _, svcName := range services {
			go launchTemporalService(svcName, *config, unifiedClient, temporalClient, logger, metrics)
		}

Checklist

  • Code compiles correctly
  • Tests for the changes have been added
  • All tests passing
  • This PR change is backwards-compatible
  • This PR CONTAINS a (planned) breaking change (it is not backwards compatible)

Related Issue

Closes #issue_number

@something-something-something something-something-something force-pushed the fix-race-condition-when-creating-bucket branch from 1cf2223 to 28177cb Compare October 15, 2025 02:21
@ktrops
Copy link
Copy Markdown
Contributor

ktrops commented Oct 28, 2025

changing bitnami to bitnamilegacy in all of the docker-compose/ dependencies.ymls should make the tests pass.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.84%. Comparing base (45f9e43) to head (5d5d484).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #594      +/-   ##
==========================================
- Coverage   65.87%   65.84%   -0.04%     
==========================================
  Files          64       64              
  Lines        6433     6433              
==========================================
- Hits         4238     4236       -2     
- Misses       1870     1872       +2     
  Partials      325      325              

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@something-something-something
Copy link
Copy Markdown
Contributor Author

changing bitnami to bitnamilegacy in all of the docker-compose/ dependencies.ymls should make the tests pass.

thanks

@ktrops
Copy link
Copy Markdown
Contributor

ktrops commented Oct 29, 2025

I think it's ok to merge even if codecov isn't passing. In my MR i've added config.

@ktrops
Copy link
Copy Markdown
Contributor

ktrops commented Oct 29, 2025

You'll need to rebase main to pull in my changes.

@ktrops ktrops merged commit d95542e into indeedeng:main Oct 29, 2025
7 checks passed
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.

3 participants