| ID | IEP-143 |
| Author | Mikhail Petrov |
| Sponsor | |
| Created |
|
| Status |
Currently, many Ignite components use the following approach: internal data (context) is attached to an operation and is accessed during its execution.
This approach is often implemented using ThreadLocal variables.
Examples of components that use the approach described above, along with their corresponding context classes:
and so on.
While the ThreadLocal approach eliminates the need for developers to manually propagate the context, it can also lead to errors when an operation is executed in a multithreaded environment.
Consider a situation in which an operation begins on one thread and continues on another. This can occur, for example, if a subtask is explicitly submitted to a thread pool or if IgniteFuture#listen is used to suspend the operation and resume it on the thread that completes the IgniteFuture.
In all such cases, the developer must manually restore the context in the thread that continues executing the operation; otherwise, the operation context stored in the ThreadLocal variable will be lost.
In some cases, losing the context associated with an operation can be critical. For example, losing the SecurityContext, which stores information about the initiator, can lead to incorrect authorization decisions and inaccurate auditing.
Examples of context propagation problems:
This IEP is intended to provide a robust mechanism for propagating arbitrary operation context that preserves the convenience of the ThreadLocal approach while minimizing the risk of operation context loss in a multithreaded environment.
The following steps are proposed to resolve the described problem:
// Describe project risks, such as API or binary compatibility issues, major protocol changes, etc.
// Links to discussions on the devlist, if applicable.
// Links to various reference documents, if applicable.
// Links or report with relevant JIRA tickets.