Skip to content

fix: agent hang on starter failure, and AWS client churn in results reporting - #596

Open
kevin-mcgoldrick wants to merge 2 commits into
masterfrom
fix/agent-hang-on-starter-failure
Open

kevin-mcgoldrick wants to merge 2 commits into
masterfrom
fix/agent-hang-on-starter-failure

Conversation

@kevin-mcgoldrick

@kevin-mcgoldrick kevin-mcgoldrick commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

1. Agent no longer hangs when a test plan starter fails

agents sat idle for hours after a stop command and after the simulation time elapsed, and the controller never terminated them.

Cause: TPSMonitor.getTPSInfo() appends to a shared ArrayList, and every test plan's starter thread and the status monitor call it concurrently. The TPSInfoContainer constructor threw ConcurrentModificationException while iterating it, which killed the starter thread from sendCloudWatchMetrics. TestPlanStarter left done = false on that path, and APITestHarness waits for every starter to be done. So the agent never logged "Test Complete", never reported Completed, and VMTerminatorImpl.terminate never ran.

Fix

  • TPSMonitor.getTPSInfo() is synchronized and returns a container built from a copy of its list.
  • TestPlanStarter sets done = true in a finally, and done is volatile.

Tests

  • New: concurrent getTPSInfo callers, and a failing metrics step for both the linear and nonlinear workloads.
  • Two tests that asserted a failed starter is not done now assert the opposite.
  • With the fix reverted, five tests fail, including the exact ConcurrentModificationException.

2. Stop building AWS clients per results batch

On jobs 15636 and 15637, agents logged tens of thousands of Unable to load credentials and Unable to load region errors. Every timing-results batch called DataBaseFactory.getDatabase(), which built new S3 and CloudWatch clients. Each build looks up region and credentials from the instance metadata service (IMDS), and those lookups failed when many user threads sent at once. The failure then escaped into the user's request thread, which recorded it as a failed request and dropped the batch.

Fix

  • DatabaseResultsReporter sends through the datasource built at construction, and logs a send failure instead of throwing it.
  • S3Datasource looks up region and hostname once, keeps per-send settings in locals now that one instance is shared, and drops a batch instead of throwing if the region isn't known yet.
  • APITestHarness decides under a lock which thread sends when a send is due, so one does rather than many, and contains a failure from the send.

Tests

  • New DatabaseResultsReporterTest, plus two APITestHarnessTest tests (one send among many threads; a reporter failure doesn't reach the calling thread).
  • All four fail without the production changes.

Not included / not verified

  • No controller-side backstop that forces Completed once simulation time is met and no user threads are alive.
  • S3Datasource itself has no unit test: its client is built in the constructor against real AWS config, so it is covered through the reporter.
  • Not run against agents under load. After a large run, check /tank/agent/agent.log for Unable to load credentials and Unable to load region.
  • DataBaseFactory still falls back to CloudWatchDataSource if the configured provider fails to construct, and the reporter keeps whichever it got for the job.

🤖 Generated with Claude Code

Job 15636 on partner never ended: starter threads died with a
ConcurrentModificationException from TPSMonitor.getTPSInfo, and
TestPlanStarter left done=false on that path. APITestHarness waits for
every starter to be done, so the agent never reported Completed and the
controller never terminated its instances, even after a stop command or
the simulation time elapsed.

- TPSMonitor.getTPSInfo is synchronized, and hands the container a
  copy of its list. Each plan's starter and the status monitor call it
  concurrently, and each call appends to that list.
- TestPlanStarter marks itself done in a finally, and done is volatile.
- The two tests that asserted a failed starter is not done now assert
  the opposite; new tests cover the concurrent callers and both
  workload types failing in the metrics step.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Agents logged tens of thousands of "Unable to load credentials" and
"Unable to load region" errors under load (jobs 15636 and 15637 on
partner). Every timing-results batch called DataBaseFactory.getDatabase(),
which built a new datasource and so new S3 and CloudWatch clients; each
build looks up the region and credentials from the instance metadata
service, and those lookups failed when many user threads sent at once.
The failure then escaped into the user's request thread, which recorded
it as a failed request and dropped the batch.

- DatabaseResultsReporter sends through the datasource it made at
  construction, and logs a send failure instead of throwing it.
- S3Datasource looks up the region and hostname once, keeps the per-send
  settings in locals now that one instance is shared, and drops a batch
  instead of throwing when the region can't be determined yet.
- APITestHarness decides under a lock which thread sends when a send is
  due, so one does rather than many, and contains a failure from it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kevin-mcgoldrick kevin-mcgoldrick changed the title fix: agent no longer hangs when a test plan starter fails fix: agent hang on starter failure, and AWS client churn in results reporting Dec 4, 2026
@kevin-mcgoldrick kevin-mcgoldrick self-assigned this Dec 5, 2026
@kevin-mcgoldrick kevin-mcgoldrick added bug AI Generated patch Increment the patch version when merged labels Dec 5, 2026

This branch has not been deployed

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

Labels

AI Generated bug patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant