[SERVER-35055] KeyedExecutor Created: 17/May/18  Updated: 29/Oct/23  Resolved: 25/May/18

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 3.6.6, 4.0.0-rc1

Type: New Feature Priority: Major - P3
Reporter: Mira Carey Assignee: Mira Carey
Resolution: Fixed Votes: 0
Labels: service_architecture_continuous_delivery
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.0, v3.6
Sprint: Platforms 2018-05-21, Platforms 2018-06-04
Participants:

 Description   

Provide a type which offers concurrent keyed and queued execution of tasks.

Something that looks like:

KeyedExecutor<std::string> ke(someExecutorMaybeThreadPool);
auto doThingFuture = ke.execute("foo", []{ return doThing(); });
auto doOtherThingFuture = ke.execute("foo", []{ return doOtherthing(); });
auto waitForCurrentFooState = ke.waitForAll("foo");

Where:

  • Jobs under the same key provide mutual exclusion
  • Tasks are executed via the passed executor
  • running jobs returns futures
  • waiting for a queue to clear up to a point is based on the back of the queue at the time of the call's future.


 Comments   
Comment by Githook User [ 25/May/18 ]

Author:

{'username': 'hanumantmk', 'name': 'Jason Carey', 'email': 'jcarey@argv.me'}

Message: SERVER-35055 keyed executor

This is a thread safe execution primitive for running jobs against an executor with mutual
exclusion and queuing by key.

Features:
Keyed - Tasks are submitted under a key. The keys serve to prevent tasks for a given key from
executing simultaneously. Tasks submitted under different keys may run concurrently.

Queued - If a task is submitted for a key and another task is already running for that key, it
is queued. I.e. tasks are run in FIFO order for a key.

Thread Safe - This is a thread safe type. Any number of callers may invoke the public api
methods simultaneously.

Special Enhancements:
onCurrentTasksDrained- Invoking this method for a key allows a caller to wait until all of the
currently queued tasks for that key have completed.

onAllCurrentTasksDrained- Invoking this method allows a caller to wait until all of the
currently queued tasks for all key have completed.

KeyedExecutorRetry - Throwing or returning KeyedExecutorRetry in a task will cause the task to
be requeued immediately into the executor and retain its place in the
queue.

(cherry picked from commit 333fdd10e3981ef3938dc4a6b5807f2f2da95110)
Branch: v3.6
https://github.com/mongodb/mongo/commit/d7a0e604b64359bde786df66a70de08394daa2da

Comment by Githook User [ 25/May/18 ]

Author:

{'username': 'hanumantmk', 'name': 'Jason Carey', 'email': 'jcarey@argv.me'}

Message: SERVER-35055 keyed executor

This is a thread safe execution primitive for running jobs against an executor with mutual
exclusion and queuing by key.

Features:
Keyed - Tasks are submitted under a key. The keys serve to prevent tasks for a given key from
executing simultaneously. Tasks submitted under different keys may run concurrently.

Queued - If a task is submitted for a key and another task is already running for that key, it
is queued. I.e. tasks are run in FIFO order for a key.

Thread Safe - This is a thread safe type. Any number of callers may invoke the public api
methods simultaneously.

Special Enhancements:
onCurrentTasksDrained- Invoking this method for a key allows a caller to wait until all of the
currently queued tasks for that key have completed.

onAllCurrentTasksDrained- Invoking this method allows a caller to wait until all of the
currently queued tasks for all key have completed.

KeyedExecutorRetry - Throwing or returning KeyedExecutorRetry in a task will cause the task to
be requeued immediately into the executor and retain its place in the
queue.

(cherry picked from commit 333fdd10e3981ef3938dc4a6b5807f2f2da95110)
Branch: v4.0
https://github.com/mongodb/mongo/commit/ca5ef64366acf031f501ddd3e58d94462cfd811e

Comment by Githook User [ 25/May/18 ]

Author:

{'username': 'hanumantmk', 'name': 'Jason Carey', 'email': 'jcarey@argv.me'}

Message: SERVER-35055 keyed executor

This is a thread safe execution primitive for running jobs against an executor with mutual
exclusion and queuing by key.

Features:
Keyed - Tasks are submitted under a key. The keys serve to prevent tasks for a given key from
executing simultaneously. Tasks submitted under different keys may run concurrently.

Queued - If a task is submitted for a key and another task is already running for that key, it
is queued. I.e. tasks are run in FIFO order for a key.

Thread Safe - This is a thread safe type. Any number of callers may invoke the public api
methods simultaneously.

Special Enhancements:
onCurrentTasksDrained- Invoking this method for a key allows a caller to wait until all of the
currently queued tasks for that key have completed.

onAllCurrentTasksDrained- Invoking this method allows a caller to wait until all of the
currently queued tasks for all key have completed.

KeyedExecutorRetry - Throwing or returning KeyedExecutorRetry in a task will cause the task to
be requeued immediately into the executor and retain its place in the
queue.
Branch: master
https://github.com/mongodb/mongo/commit/333fdd10e3981ef3938dc4a6b5807f2f2da95110

Generated at Thu Feb 08 04:38:41 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.