@@ -40,20 +40,21 @@ box.stat.memtx().tx
4040 (equals ``total `` / number of open transactions).
4141 * ``max `` is the maximal number of bytes that a single transaction uses.
4242
43- * ``box.stat.memtx().tx.mvcc `` shows memory allocation related to multiversion
44- concurrency control (MVCC). MVCC is reponsible for isolating transactions.
43+ * ``box.stat.memtx().tx.mvcc `` shows memory allocation related to
44+ :ref: `multiversion concurrency control (MVCC) <txn_mode_transaction-manager >`.
45+ MVCC is reponsible for isolating transactions.
4546 It reveals conflicts and makes sure that tuples that do not belong to a particular
4647 space but were (or could be) read by some transaction were not deleted.
4748
4849 It consists of the following sections:
4950
5051 * ``trackers `` is the memory allocated for *trackers * of transaction reads.
5152 Like in the previous sections, Tarantool reports the total, average
52- and maximum number of bytes allocated for trackers per a single transaction.
53+ and maximal number of bytes allocated for trackers per a single transaction.
5354 * ``conflicts `` is the memory allocated for *conflicts *
5455 which are entities created when transactional conflicts occur.
5556 Like in the previous sections, Tarantool reports the total, average
56- and maximum number of allocated bytes.
57+ and maximal number of allocated bytes.
5758 * ``tuples `` is the memory allocated for storing tuples.
5859 With MVCC, tuples are stored using the *stories * mechanism. Nearly every
5960 tuple has its story. Even tuples in an index may have their stories, so
@@ -79,3 +80,91 @@ box.stat.memtx().tx
7980
8081 * ``count `` is the number of stories or retained tuples.
8182 * ``total `` is the number of bytes allocated for stories or retained tuples.
83+
84+ **Example **
85+
86+ Let's take a look at `used ` and `retained ` tuples in a transaction.
87+
88+ Within the first ``box.cfg() `` call to a new Tarantool instance, we
89+ :ref: `enable the MVCC engine <txn_mode_mvcc-enabling >`:
90+
91+ .. code-block :: console
92+
93+ box.cfg{memtx_use_mvcc_engine = true}
94+
95+ Next, we create a space with a primary index, and begin a transaction:
96+
97+ .. code-block :: console
98+
99+ box.schema.space.create('test')
100+ box.space.test:create_index('pk')
101+
102+ box.begin()
103+ box.space.test:replace{0, 0}
104+ box.space.test:replace{0, string.rep('a', 100)}
105+ box.space.test:replace{0, 1}
106+ box.space.test:replace{1, 1}
107+ box.space.test:replace{2, 1}
108+
109+ In the transaction above, we replace three tuples by the `0 ` key:
110+
111+ * ``{0, 0} ``
112+ * ``{0, 'aa...aa'} ``
113+ * ``{0, 1} ``
114+
115+ MVCC considers all these tuples as `used ` since they belong to the current transaction.
116+ Meanwhile, MVCC considers tuples ``{0, 0} `` and ``{0, 'aa..aa'} `` as `retained ` because
117+ they don't belong to any index (unlike ``{0, 1} ``), but they cannot be deleted yet.
118+
119+ If we call ``box.stat.memtx.tx() `` now, we'll see something like this:
120+
121+ .. code-block :: javascript
122+ : emphasize- lines: 33 - 39
123+
124+ tarantool> box .stat .memtx .tx ()
125+ -- -
126+ - txn:
127+ statements:
128+ max: 720
129+ avg: 720
130+ total: 720
131+ user:
132+ max: 0
133+ avg: 0
134+ total: 0
135+ system:
136+ max: 916
137+ avg: 916
138+ total: 916
139+ mvcc:
140+ trackers:
141+ max: 0
142+ avg: 0
143+ total: 0
144+ conflicts:
145+ max: 0
146+ avg: 0
147+ total: 0
148+ tuples:
149+ tracking:
150+ stories:
151+ count: 0
152+ total: 0
153+ retained:
154+ count: 0
155+ total: 0
156+ used:
157+ stories:
158+ count: 6
159+ total: 944
160+ retained:
161+ count: 2
162+ total: 119
163+ read_view:
164+ stories:
165+ count: 0
166+ total: 0
167+ retained:
168+ count: 0
169+ total: 0
170+ ...
0 commit comments