daml/compiler/scenario-service
Moritz Kiefer 3554596f9a Wait for all gRPC requests to finish before shutting down gRPC (#2551)
This fixes all flakiness in `damlc test` that I was able to
reproduce. Previously, I got it to fail in about 10% of the cases
whereas now I have successfully run tests 200 times under load without
issues.

There were two issues at play here:

1. We run scenarios in separate threads to be able to kill the running
Shake session quickly even if a scenario has an infinite loop or
something like that (there is a timeout but it’s quite long). This
could result in one of those left-over threads trying to issue a
request while we are already trying to shut down.

To fix that, we wait for the concurrency semaphore to be empty before
shutting down.

2. Just waiting for scenario executions is not quite sufficient as
`runAction` does not wait for all rules to finish (we could just use
runActionSync in `damlc test` but I’d rather make this work
properly). While we do wait for all scenario executions to finish
there is one gRPC request in offInterest that we do not wait for:
gcCtxs.

To fix this, I’ve now routed all gRPC requests through the semaphore
which means that we will also wait for these requests to finish (or
prevent them from spawning).

This makes more sense anyway as scenario executions are mostly fairly
cheap requests while things like setting up the context are expensive
so we want to limit their concurrency.

We should make the concurrency limit configurable but I’ll leave that
for a separate PR.
2019-08-15 09:39:30 +00:00
..
client Wait for all gRPC requests to finish before shutting down gRPC (#2551) 2019-08-15 09:39:30 +00:00
protos Show function names in stack trace on failing scenario (#2516) 2019-08-14 09:16:07 +02:00
server Show function names in stack trace on failing scenario (#2516) 2019-08-14 09:16:07 +02:00