Skip to content

[v2] Reduce session database locking - #10522

Open
kdaily wants to merge 1 commit into
v2from
kdaily/session-locking
Open

[v2] Reduce session database locking#10522
kdaily wants to merge 1 commit into
v2from
kdaily/session-locking

Conversation

@kdaily

@kdaily kdaily commented Jul 31, 2026

Copy link
Copy Markdown
Member

Issue #, if available:

Continuation of #10517 but only the session locking component; the environment variable was merged in #10519.

Description of changes:

CLI v2 stores a "session ID" in a SQLite database in the ~/.aws directory. This stores a random ID that is rotated every 30 minutes, which allows some services to group command invocations together.

This makes some changes to SQLite usage to reduce lock contention on the database when multiple commands are run on the same host concurrently.

  • Only writes the timestamp for the current session every 60 seconds, rather than every invocation.
  • The sweeper, which deletes old sessions, first checks if any exists before writing.
  • Shortens the lock timeout to 100ms, rather than the default of 5s. Session IDs are best effort.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Reduce write-lock contention on the session database, which can cause
slowdowns when the AWS CLI cache directory is on a network filesystem.

- Add a check-before-delete in the sweeper to avoid taking a write lock
  when there are no expired records to remove
- Only refresh the stored timestamp when it is older than 60 seconds,
  avoiding a write on every invocation
- Set a short busy timeout (100ms) so the CLI does not block waiting for
  a database lock
- Add debug logging for database errors instead of silently passing
@kdaily
kdaily requested a review from a team as a code owner July 31, 2026 21:30
@kdaily kdaily added the v2 label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants