fix(#6420): make ImportProfile concurrency-safe with hash-based caching - #6421
Open
fullsend-ai-coder[bot] wants to merge 1 commit into
Open
fix(#6420): make ImportProfile concurrency-safe with hash-based caching#6421fullsend-ai-coder[bot] wants to merge 1 commit into
fullsend-ai-coder[bot] wants to merge 1 commit into
Conversation
ImportProfile unconditionally deleted a provider profile by ID before re-importing, causing race conditions when multiple fullsend run invocations shared the same gateway. One process could delete a profile that another had just imported, causing EnsureProvider to fail with "unsupported provider type or profile". Mirror the hash-based idempotency pattern from ImportProfiles: compute a SHA-256 digest of the profile file, compare against a temp-file cache keyed by profile ID, and skip delete+reimport when the hash matches. On cache miss or content change, proceed with delete+reimport as before, writing the cache on success (including when a parallel process already imported the profile). Add hashProfileFile and profileFileCachePath helpers as single-file analogs of hashProfileDir and profileCachePath. Update existing tests to use real temp files (required now that ImportProfile reads the file for hashing). Add tests for cache hit/miss, cache write on success and already-exists, concurrent access, and the new helper functions. Closes #6420
|
🤖 Finished Review · ✅ Success · Started 5:04 PM UTC · Completed 5:15 PM UTC Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Looks good to me |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
ImportProfileconcurrency-safe by adding hash-based caching, mirroring the existing pattern inImportProfiles. When multiplefullsend runinvocations share the same gateway,ImportProfilepreviously did an unconditional delete-then-reimport that caused race conditions — one process could delete a profile another had just imported, causing downstreamEnsureProviderfailures.Related Issue
Changes
ImportProfilekeyed by profile ID in a temp filehashProfileFileandprofileFileCachePathhelper functionsTesting
TestImportProfile_*tests pass with updated profile file pathsTestImportProfile_SkipsWhenCacheMatchesverifies cache hit pathTestImportProfile_ReimportsWhenCacheDiffersverifies cache miss pathTestImportProfile_WritesCacheOnSuccessverifies cache write after importTestImportProfile_WritesCacheOnAlreadyExistsverifies cache write on parallel importTestImportProfile_ConcurrentAccesswith 12 goroutines verifies safety under concurrent accessgo test -race ./internal/sandbox/...passesgo vet ./internal/sandbox/...passesCloses #6420
Post-script verification
agent/6420-import-profile-concurrency)2c7812ac854a60d19d4be0c1eeed49c69bb15976..HEAD)