Skip to content

Commit 0e8bc90

Browse files
sergeypospelovDomonion
authored andcommitted
Fix: document
1 parent 848167a commit 0e8bc90

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

docs/ResultAndErrorHandlingApiOfTheInstrumentedProcess.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44

55
- The _instrumented process_ is an external process used for the isolated invocation.
66
- The `ConcreteExecutor` is a class which provides smooth and concise interaction with the _instrumented process_. It works in the _main process_.
7-
- A client is an object which directly uses `ConcreteExecutor`, so it works in the _main process_ as well.
8-
- An _Instrumentation_ is an object which should be passed to `ConcreteExecutor`. It defines the logic of invocation and bytecode instrumentation in the _instrumented process_.
7+
- A client is an object which directly uses the `ConcreteExecutor`, so it works in the _main process_ as well.
8+
- An _Instrumentation_ is an object which has to be passed to the `ConcreteExecutor`. It defines the logic of invocation and bytecode instrumentation in the _instrumented process_.
99

1010
## Common
1111

1212
Basically, if any exception happens inside the _instrumented process_, it is rethrown to the client process via RD.
13-
- Some of the errors lead to the instant death of the _instrumented process_. Such errors are wrapped in `InstrumentedProcessDeathException`. Before processing the next request, the _instrumented process_ will be restarted automatically, but it can take some time.
14-
- Errors which do not cause the termination of the _instrumented process_ are wrapped in `InstrumentedProcessError`. Process won't be restarted, so client's requests will be handled by the same process. We believe, that the state of the _instrumented process_ is consistent, but in some tricky situations it may be not.
13+
- Errors which do not cause the termination of the _instrumented process_ are wrapped in `InstrumentedProcessError`. Process won't be restarted, so client's requests will be handled by the same process. We believe, that the state of the _instrumented process_ is consistent, but in some tricky situations it **may be not**. Such situations should be reported as bugs.
14+
- Some of the errors lead to the instant death of the _instrumented process_. Such errors are wrapped in `InstrumentedProcessDeathException`. Before processing the next request, the _instrumented process_ will be restarted automatically, but it can take some time.
1515

1616
The extra logic of error and result handling depends on the provided instrumentation.
1717

18-
## UtConcreteExecutionInstrumentation
18+
## UtExecutionInstrumentation
1919

2020
The next sections are related only to the `UtExecutionInstrumentation` passed to the _instrumented process_.
2121

2222
The calling of `ConcreteExecutor::executeAsync` instantiated by the `UtExecutionInstrumentation` can lead to the three possible situations:
2323
- `InstrumentedProcessDeathException` occurs. Usually, this situation means there is an internal issue in the _instrumented process_, but, nevertheless, this exception should be handled by the client.
2424
- `InstrumentedProcessError` occurs. It also means an internal issue and should be handled by the client. Sometimes it happens because the client provided the wrong configuration or parameters, but the _instrumented process_ **can't determine exactly** what's wrong with the client's data. The cause contains the description of the phase which threw the exception.
25-
- No exception occurs, so the `UtConcreteExecutionResult` is returned. It means that everything went well during the invocation or something broke down because of the wrong input, and the _instrumented process_ **knows exactly** what's wrong with the client's input. The _instrumented process_ guarantee that the state **is consistent**. The exact reason of failure is a `UtConcreteExecutionResult::result` field. It includes:
25+
- No exception occurs, so the `UtConcreteExecutionResult` is returned. It means that everything went well during the invocation or something broke down because of the wrong input, and the _instrumented process_ **knows exactly** what's wrong with the client's input. The _instrumented process_ guarantees that the state **is consistent**. The exact reason of failure is a `UtConcreteExecutionResult::result` field. It includes:
2626
- `UtSandboxFailure` --- violation of permissions.
2727
- `UtTimeoutException` --- the test execution time exceeds the provided time limit (`UtConcreteExecutionData::timeout`).
2828
- `UtExecutionSuccess` --- the test executed successfully.
@@ -32,24 +32,24 @@ The calling of `ConcreteExecutor::executeAsync` instantiated by the `UtExecution
3232

3333
### How the error handling works
3434

35-
The flow of the `UtExecutionInstrumentation::invoke` consists of 6 phases:
35+
The pipeline of the `UtExecutionInstrumentation::invoke` consists of 6 phases:
3636
- `ValueConstructionPhase` --- constructs values from the models.
3737
- `PreparationPhase` --- prepares statics, etc.
3838
- `InvocationPhase` --- invokes the target method.
3939
- `StatisticsCollectionPhase` --- collects the coverage and execution-related data.
40-
- `ModelConstructionPhase` --- constructs the result models from.
40+
- `ModelConstructionPhase` --- constructs the result models from the heap objects (`Any?`).
4141
- `PostprocessingPhase` --- restores statics, clear mocks, etc.
4242

4343
Each phase can throw two kinds of exceptions:
44-
- `ExecutionPhaseStop` --- indicates that the phase want to stop the invocation pipeline completely, because it's already has a result. The returned result is the `ExecutionPhaseStop::result` field.
44+
- `ExecutionPhaseStop` --- indicates that the phase want to stop the invocation of the pipeline completely, because it's already has a result. The returned result is the `ExecutionPhaseStop::result` field.
4545
- `ExecutionPhaseError` --- indicates that an unexpected error happened inside the phase execution, so it's rethrown to the main process.
4646

4747
The `PhasesController::computeConcreteExecutionResult` then matches on the exception type and rethrows the exception if it's an `ExecutionPhaseError`, and returns the result if it's an `ExecutionPhaseStop`.
4848

4949
### Timeout
5050

51-
There is a time limit on the concrete execution, so the `UtExecutionInstrumentation::invoke` method must respect. We wrap phases which can take a long time with the `executePhaseInTimeout` block, which internally keeps and updates the elapsed time. If any wrapped phase exceeds the timeout, we return the `TimeoutException` as the result of that phase.
51+
There is a time limit on the concrete execution, so the `UtExecutionInstrumentation::invoke` method must respect it. We wrap phases which can take a long time with the `executePhaseInTimeout` block, which internally keeps and updates the elapsed time. If any wrapped phase exceeds the timeout, we return the `TimeoutException` as the result of that phase.
5252

53-
The clients cannot depend that cancellation request immediately breaks the invocation inside the _instrumented process_. The invocation is guaranteed to finish in the time of passed timeout, but not earlier.
53+
The clients cannot depend that cancellation request immediately breaks the invocation inside the _instrumented process_. The invocation is guaranteed to finish in the time of passed timeout. It may or **may not** finish earlier. Already started query in instrumented process is **uncancellable** - this is by design.
5454

55-
Even if the `TimeoutException` occurs, the _instrumented process_ is ready to receive new requests.
55+
Even if the `TimeoutException` occurs, the _instrumented process_ is ready to process new requests.

0 commit comments

Comments
 (0)