-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Labels:
-
Service Arch
-
Fully Compatible
-
Service Arch 2023-03-20, Service Arch 2023-04-03
-
105
It would be nice to have an executor compatible with ExecutorFutures that executes its tasks inline on the caller's thread so we can run code written to be async compatible synchronously (like QueuedImmediateExecutor from facebook/folly). This would be especially useful for the recently added TransactionWithRetries type, which executes transaction commands on a given executor but every current use is in a synchronous context.
We already have the InlineQueuedCountingExecutor which seems to do this, but it's in a test file so is probably not production quality.
The initial use case for this will be `SyncTransactionWithRetries::runNoThrow`, which currently runs a work on an executor while using `get` to cause the main thread to wait. In this situation, there is no reason for the work to be run on a different thread.
This can be solved with a new type `ManuallyManagedExecutor`.
Before:
Future fut = somethingThatTakesAnExecutor(_exec);
fut.get(); // Blocking call if fut is not ready. Work is done on a thread owned by `_exec`.
After:
ManuallyManagedExecutor exec(); Future fut = somethingThatTakesAnExecutor(exec); exec.runUntilReady(fut); // Work is done on this thread. fut.get(); // Not a blocking call because we know fut is ready.
Note: There are complications associated with the existing usage patterns around executors. Generally executors are managed with shared_ptr. This means that a function taking this sort of executor might hold onto it longer than the caller expected. The correct implementation will need to take this into account and have some concept of an owner, so when the owner goes out of scope, it can reject work or maybe forward work to a fallback executor (otherwise accidental users of this executor will just hang).
- causes
-
SERVER-82313 Fix cancelling txn api from the caller
-
- Closed
-
- is depended on by
-
SERVER-72701 Create a synchronous transaction API for SyncTransactionWithRetries
-
- Closed
-
- related to
-
SERVER-76363 Complete TODO listed in SERVER-66261
-
- Backlog
-
-
SERVER-75166 Complete TODO listed in SERVER-66261
-
- Closed
-
-
SERVER-75291 Complete TODO listed in SERVER-66261
-
- Closed
-
-
SERVER-76030 Complete TODO listed in SERVER-66261
-
- Closed
-