Skip to content

fix: resolve EnvironmentProvider race under concurrent resolveEnvironment()#169

Open
dminkley wants to merge 1 commit into
awslabs:masterfrom
dminkley:fix/168-environmentprovider-race
Open

fix: resolve EnvironmentProvider race under concurrent resolveEnvironment()#169
dminkley wants to merge 1 commit into
awslabs:masterfrom
dminkley:fix/168-environmentprovider-race

Conversation

@dminkley

Copy link
Copy Markdown

resolveEnvironment() let multiple threads past the null check before the
CompletableFuture resolved, so probe() could run on several Environments
concurrently and a non-deterministic one could win the cache. Under ECS +
FireLens this intermittently cached an ECSEnvironment whose getLogGroupName()
is "", dropping the LogGroup dimension for the JVM's lifetime.

Make cachedEnvironment volatile and resolve it once via double-checked
locking. Add a deterministic regression test that forces concurrent callers
and asserts probe() runs exactly once.

Fixes #168

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

  resolveEnvironment() let multiple threads past the null check before the
  CompletableFuture resolved, so probe() could run on several Environments
  concurrently and a non-deterministic one could win the cache. Under ECS +
  FireLens this intermittently cached an ECSEnvironment whose getLogGroupName()
  is "", dropping the LogGroup dimension for the JVM's lifetime.

  Make cachedEnvironment volatile and resolve it once via double-checked
  locking. Add a deterministic regression test that forces concurrent callers
  and asserts probe() runs exactly once.

  Fixes awslabs#168
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.

Race in EnvironmentProvider.resolveEnvironment() yields non-deterministic ECSEnvironment.getLogGroupName() under FireLens

1 participant