Skip to content

Commit

Permalink
Rename new mloginfo options to --cursors and --transactions for consi…
Browse files Browse the repository at this point in the history
…stency
  • Loading branch information
stennie committed Dec 27, 2019
1 parent c0f8706 commit 3d0d760
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 62 deletions.
109 changes: 55 additions & 54 deletions doc/mloginfo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Usage
mloginfo [-h] [--version] logfile
[--verbose]
[--queries] [--restarts] [--distinct] [--connections] [--rsstate]
[--clients]
[--cursors]
[--storagestats]
[--transactions] [--tsort {duration}]
[--cursor]
General Parameters
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -142,53 +143,6 @@ example:
This option has no effect unless ``--queries`` is also specified.

Transactions (``--transactions``)
---------------------------------

The transaction section will parse the log file to find information related
to transactions (MongoDB 4.0+). ``autocommit`` indicates whether ``autocommit``
was enabled for a transaction. The ``readConcern`` information is fetched
either from ``OperationContext`` or ``_txnResourceStash``. ``TimeActiveMicros``
and ``TimeInactiveMicros`` denote the number of micros active and inactive
during the span of the transaction. The ``duration`` field includes the value
in milliseconds and indicates the amount of time taken by each transaction.

For example:

.. code-block:: bash
mloginfo mongod.log --transactions
In addition to the default information, this command will also output the
``TRANSACTIONS`` section:

.. code-block:: bash
TRANSACTION
DATETIME TXNNUMBER AUTOCOMMIT READCONCERN TIMEACTIVEMICROS TIMEINACTIVEMICROS DURATION
2019-06-18T12:31:03.180+0100 1 false "snapshot" 11142 3 7
2019-03-18T12:31:03.180+0100 2 false "snapshot" 11143 4 6
2019-07-18T12:31:03.180+0100 3 false "snapshot" 11144 3 4
2019-08-18T12:31:03.180+0100 4 false "snapshot" 11145 4 7
2019-06-18T12:31:03.180+0100 5 false "snapshot" 11146 3 3
``--tsort``
^^^^^^^^^^^

This option can be used to sort the results of the ``--transaction`` table,
along with 'duration' keyword.

For example:

.. code-block:: bash
mloginfo mongod.log --transaction --tsort duration
This option has no effect unless it is specified between ``--transaction`` and
``duration`` is specified.

Restarts (``--restarts``)
-------------------------

Expand Down Expand Up @@ -314,18 +268,65 @@ state changes.
Oct 07 23:23:32 example.com:27018 RECOVERING
Oct 07 23:23:34 example.com:27018 SECONDARY
Cursor (``--cursor``)
Transactions (``--transactions``)
---------------------------------

The transaction section will parse the log file to find information related
to transactions (MongoDB 4.0+). ``autocommit`` indicates whether ``autocommit``
was enabled for a transaction. The ``readConcern`` information is fetched
either from ``OperationContext`` or ``_txnResourceStash``. ``TimeActiveMicros``
and ``TimeInactiveMicros`` denote the number of micros active and inactive
during the span of the transaction. The ``duration`` field includes the value
in milliseconds and indicates the amount of time taken by each transaction.

For example:

.. code-block:: bash
mloginfo mongod.log --transactions
In addition to the default information, this command will also output the
``TRANSACTIONS`` section:

.. code-block:: bash
TRANSACTION
DATETIME TXNNUMBER AUTOCOMMIT READCONCERN TIMEACTIVEMICROS TIMEINACTIVEMICROS DURATION
2019-06-18T12:31:03.180+0100 1 false "snapshot" 11142 3 7
2019-03-18T12:31:03.180+0100 2 false "snapshot" 11143 4 6
2019-07-18T12:31:03.180+0100 3 false "snapshot" 11144 3 4
2019-08-18T12:31:03.180+0100 4 false "snapshot" 11145 4 7
2019-06-18T12:31:03.180+0100 5 false "snapshot" 11146 3 3
``--tsort``
^^^^^^^^^^^

This option can be used to sort the results of the ``--transaction`` table,
along with 'duration' keyword.

For example:

.. code-block:: bash
mloginfo mongod.log --transaction --tsort duration
This option has no effect unless it is specified between ``--transaction`` and
``duration`` is specified.

Cursors (``--cursors``)
-----------------------------------------

Outputs information if the cursor was reaped for exceeding the transaction
Outputs information if a cursor was reaped for exceeding the transaction
timeout. The timestamp of transaction, Cursor ID, and the time at which the
cursor was reaped is captured from the logs.

For example:

.. code-block:: bash
mloginfo mongod.log --cursor
mloginfo mongod.log --cursors
.. code-block:: bash
Expand All @@ -340,7 +341,7 @@ For example:
Storage Stats (``--storagestats``)
-----------------------------------------

Outputs the information about the storage statistics for slow transactions.
Outputs information about the storage statistics for slow transactions.

For example:

Expand All @@ -358,5 +359,5 @@ For example:
local.myCollection insert None None None None
local.myCollection update None None None None
local1.myCollection insert None None None None
invoice-prod.invoices insert 12768411 22233323 86313 12344
invoice-prod.invoices insert 12868411 22233323 86313 12344
invoice-prod.invoices insert 12768411 22233323 86313 12344
invoice-prod.invoices insert 12868411 22233323 86313 12344
4 changes: 2 additions & 2 deletions mtools/mloginfo/sections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from .clients_section import ClientSection
from .connection_section import ConnectionSection
from .cursor_section import CursorSection
from .cursors_section import CursorSection
from .distinct_section import DistinctSection
from .query_section import QuerySection
from .restart_section import RestartSection
from .rs_info_section import RsInfoSection
from .rs_state_section import RsStateSection
from .storagestats_section import StorageStatsSection
from .transaction_section import TransactionSection
from .transactions_section import TransactionSection
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ def op_or_cmd(le):
class CursorSection(BaseSection):
"""CursorSection class."""

name = 'cursor'
name = 'cursors'

def __init__(self, mloginfo):
BaseSection.__init__(self, mloginfo)
helptext = 'outputs statistics about cursor'
self.mloginfo.argparser_sectiongroup.add_argument('--cursor',
helptext = 'outputs statistics about cursors'
self.mloginfo.argparser_sectiongroup.add_argument('--cursors',
action='store_true',
help=helptext)

@property
def active(self):
"""Return boolean if this section is active."""
return self.mloginfo.args['cursor']
return self.mloginfo.args['cursors']

def run(self):
"""Run this section and print out information."""
Expand Down
4 changes: 2 additions & 2 deletions mtools/test/test_mloginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ def test_transactions_output(self):
assert any(map(lambda line: 'TRANSACTIONS' in line, lines))
assert any(map(lambda line: line.startswith('DATETIME'), lines))

def test_cursor_output(self):
def test_cursors_output(self):
# different log file
logfile_path = "mtools/test/logfiles/mongod_4.0.10_reapedcursor.log"
self.tool.run('%s --cursor' % logfile_path)
self.tool.run('%s --cursors' % logfile_path)
output = sys.stdout.getvalue()
lines = output.splitlines()
assert any('CURSOR' in line for line in lines)
Expand Down

0 comments on commit 3d0d760

Please sign in to comment.