Skip to content

Fix .aws/config destroying multi-process concurrency bug#16

Draft
snickell wants to merge 1 commit intomainfrom
seth/unable-to-parse-config-file-bug
Draft

Fix .aws/config destroying multi-process concurrency bug#16
snickell wants to merge 1 commit intomainfrom
seth/unable-to-parse-config-file-bug

Conversation

@snickell
Copy link

@snickell snickell commented Mar 21, 2026

Fix multiprocess concurrency bug that trashes ~/.aws files

Prevents the error: Unable to parse config file: where you have to either fix ~/.aws/config or delete ~/.aws/credentials. Suddenly its rock solid!

We previously had a mutex to try to prevent the worst of these, but this only works with threads. If multiple processes try to use aws-google at once, they can simultaneously run aws configure set ... which writes to both ~/.aws/config and ~/.aws/credentials, trashing one or the other.

The solution in this PR is to use an flock on ~/.aws/aws-google.lock, which can synchronize access by multiple processes. To prevent infinite hangs, processes will only block for 60s on the lock before raising an exception.

Because an flock is a kernel level feature on a file descriptor, when the descriptor is destroyed, even if the process ends in a SEGFAULT or whatever, the kernel should delete the lockfile.

Testing

  • Was able to verify the issue with moderate consistency (about 2/3 times it corrupted) by launching 20x bin/aws_access runs at once.
  • After this PR, I can't get it to corrupt the file.
  • Adds tests written by codex, but frankly, I've only skimmed the tests

@snickell snickell changed the title Fix config trashing multi-process concurrency bug in aws-google Fix .aws/config destroying multi-process concurrency bug Mar 21, 2026
@snickell snickell force-pushed the seth/unable-to-parse-config-file-bug branch from 09fd5a2 to 8f3137b Compare March 21, 2026 09:50
@snickell snickell marked this pull request as draft March 21, 2026 10:38
@snickell
Copy link
Author

Hmmm, found what might be an issue, or maybe I'm just using it wrong locally from the source dir? Going draft since I'm on vacation for a bit.

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