Skip to content

cleanup of JavaScript lock in reference pages #746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions source/applications/map-reduce.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,7 @@ The map-reduce operation is composed of many tasks, including:
These various tasks take the following locks:

- The read phase takes a read lock. It yields every 100 documents.

- The JavaScript code (i.e. ``map``, ``reduce``, ``finalize``
functions) is executed in a single thread, taking a JavaScript lock;
however, most JavaScript tasks in map-reduce are very short and
yield the lock frequently.


- The insert into the temporary collection takes a write lock for a
single write.

Expand All @@ -242,8 +237,11 @@ These various tasks take the following locks:
If the output collection exists, then the output actions (i.e.
``merge``, ``replace``, ``reduce``) take a write lock.

Although single-threaded, the map-reduce tasks interleave and appear to
run in parallel.
.. versionchanged:: 2.4
The V8 JavaScript engine added in 2.4 allows multiple JavaScript
operations to run at the same time. Prior to 2.4, JavaScript code
(i.e. ``map``, ``reduce``, ``finalize`` functions) executed in a
single thread, taking a JavaScript lock.

.. note::

Expand Down
9 changes: 5 additions & 4 deletions source/reference/command/eval.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ eval

- .. include:: /includes/fact-eval-lock.rst

- :dbcommand:`eval` also takes a JavaScript lock.

.. modified in 2.4 version, the JavaScript lock is up to and including version 2.2

- Do not use :dbcommand:`eval` for long running operations as
:dbcommand:`eval` blocks all other operations. Consider using
:doc:`other server side code execution options
Expand All @@ -158,4 +154,9 @@ eval

- .. include:: /includes/fact-eval-authentication.rst

.. versionchanged:: 2.4
The V8 JavaScript engine added in 2.4 allows multiple JavaScript
operations to run at the same time. Prior to 2.4,
:dbcommand:`eval` would take a JavaScript lock.

.. seealso:: :doc:`/applications/server-side-javascript`
15 changes: 7 additions & 8 deletions source/reference/command/group.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,10 @@ group

.. warning::

- The :dbcommand:`group` command does not work with
:term:`sharded clusters <sharded cluster>`. Use the
:term:`aggregation framework` or :term:`map-reduce` in
:term:`sharded environments <sharding>`.

- The :dbcommand:`group` command takes a read lock and does not
allow any other threads to execute JavaScript while it is
running.
The :dbcommand:`group` command does not work with :term:`sharded
clusters <sharded cluster>`. Use the :term:`aggregation
framework` or :term:`map-reduce` in :term:`sharded environments
<sharding>`.

.. note::

Expand All @@ -92,6 +88,9 @@ group

- .. include:: /includes/fact-group-map-reduce-where-limitations-in-24.rst

- Prior to 2.4, the :dbcommand:`group` command took a JavaScript
lock.

For the shell, MongoDB provides a wrapper method
:method:`db.collection.group()`; however, the
:method:`db.collection.group()` method takes the ``keyf`` field and
Expand Down
15 changes: 7 additions & 8 deletions source/reference/method/db.collection.group.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ db.collection.group()

.. warning::

- The :method:`db.collection.group()` method does not work with
:term:`sharded clusters <sharded cluster>`. Use the
:term:`aggregation framework` or :term:`map-reduce` in
:term:`sharded environments <sharding>`.

- The :dbcommand:`group` command takes a read lock and does not
allow any other threads to execute JavaScript while it is
running.
The :method:`db.collection.group()` method does not work with
:term:`sharded clusters <sharded cluster>`. Use the
:term:`aggregation framework` or :term:`map-reduce` in
:term:`sharded environments <sharding>`.

.. note::

Expand All @@ -76,6 +72,9 @@ db.collection.group()

- .. include:: /includes/fact-group-map-reduce-where-limitations-in-24.rst

- Prior to 2.4, the :method:`db.collection.group()` method took a
JavaScript lock.

Consider the following examples of the :method:`db.collection.group()` method:

The examples assume an ``orders`` collection with documents of the
Expand Down
9 changes: 5 additions & 4 deletions source/reference/method/db.eval.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ db.eval()
.. |nolockobject| replace:: :dbcommand:`eval` *command*

- .. include:: /includes/fact-eval-lock.rst

- :method:`db.eval()` also takes a JavaScript lock.

.. modified in 2.4 version, the JavaScript lock is up to and including version 2.2

- Do not use :method:`db.eval()` for long running operations, as
:method:`db.eval()` blocks all other operations. Consider using
Expand All @@ -116,6 +112,11 @@ db.eval()

- .. include:: /includes/fact-eval-authentication.rst

.. versionchanged:: 2.4
The V8 JavaScript engine added in 2.4 allows multiple JavaScript
operations to run at the same time. Prior to 2.4,
:method:`db.eval()` would take a JavaScript lock.

.. seealso::

:doc:`/applications/server-side-javascript`