File: grndb.rst

package info (click to toggle)
groonga 15.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 163,080 kB
  • sloc: ansic: 770,564; cpp: 48,925; ruby: 40,447; javascript: 10,250; yacc: 7,045; sh: 5,602; python: 2,821; makefile: 1,672
file content (295 lines) | stat: -rw-r--r-- 9,277 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
.. -*- rst -*-

``grndb``
=========

Summary
-------

.. versionadded:: 4.0.9

``grndb`` manages a Groonga database.

Here are features:

  * Checks whether database is broken or not.
  * Recovers broken database automatically if the database is
    recoverable.

Syntax
------

``grndb`` requires command and database path::

  grndb COMMAND [OPTIONS] DATABASE_PATH

Here are available commands:

  * ``check`` - Checks whether database is broken or not.
  * ``recover`` - Recovers database.

Usage
-----

Here is an example to check the database at ``/var/lib/groonga/db/db``::

  % grndb check /var/lib/groonga/db/db

Here is an example to recover the database at ``/var/lib/groonga/db/db``::

  % grndb recover /var/lib/groonga/db/db

Commands
--------

This section describes available commands.

``check``
^^^^^^^^^

It checks an existing Groonga database. If the database is broken,
``grndb`` reports reasons and exits with non-``0`` exit status.

.. note::

   You must not use this command for opened database. If the database
   is opened, this command may report wrong result.

``check`` has some options.

``--target``
""""""""""""

.. versionadded:: 5.1.2

It specifies a check target object.

If your database is large and you know an unreliable object, this
option will help you. ``check`` need more time for large database. You
can reduce check time by ``--target`` option to reduce check target.

The check target is checked recursive. Because related objects of
unreliable object will be unreliable.

If the check target is a table, all columns of the table are also
checked recursive.

If the check target is a table and its key type is another table, the
another table is also checked recursive.

If the check target is a column and its value type is a table, the
table is also checked recursive.

If the check target is an index column, the table specified as value
type and all sources are also checked recursive.

Here is an example that checks only ``Entries`` table and its
columns::

  % grndb check --target Entries /var/lib/groonga/db/db

Here is an example that checks only ``Entries.name`` column::

  % grndb check --target Entries.name /var/lib/groonga/db/db

``--log-level``
"""""""""""""""

.. versionadded:: 7.0.4

It specifies a log level of ``grndb`` log.

Here is an example that specifies ``--log-level`` option::

  % grndb check --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

See :doc:`/reference/commands/log_level` to know about supported log level.

``--log-path``
""""""""""""""

.. versionadded:: 7.0.4

It specifies a path of ``grndb`` log.

Here is an example that specifies ``--log-path`` option::

  % grndb check --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

``--log-flags``
"""""""""""""""

.. versionadded:: 9.0.3

It specifies a logged content in ``grndb`` log by flags.
The default value of ``--log-flags`` is ``time|message``. It means that timestamp and log messages are logged into ``grndb`` log.

Here is an example that specifies ``--log-flags`` option::

  % grndb check --log-path /var/log/groonga/grndb.log --log-flags "time|pid|message" /var/lib/groonga/db/db

See :doc:`groonga` to know about supported log flags.

``--since``
"""""""""""

.. versionadded:: 9.0.4

It specifies the object's modified time which should be checked. If object's modified time is newer than the specified time, these objects are checked by ``grndb``.
You can specify the modified time as ISO 8601 format or ``-NUNIT`` format such as -3days or -2.5weeks format.

Here is an example that specifies ``--since`` option in ISO 8601 format::

  % grmdb check --since=2019-06-24T18:16:22 /var/lib/groonga/db/db

In above example, the objects which are modified after ``2019-06-24T18:16:22`` are checked.

Here is an example that specifies ``--since`` option in ``-NUNIT`` format::

  % grmdb check --since=-7d /var/lib/groonga/db/db

In above example, the objects which are modified in recent 7 days are checked.

``-NUNIT`` accepts the following suffix as a unit.

.. list-table::
   :header-rows: 1

   * - Supported suffix
     - Description
   * - ``s``, ``sec``, ``secs``, ``second``, ``seconds``
     - Specify recent N seconds. For example, ``--since=-100s`` means within recent 100 seconds should be checked.
   * - ``m``, ``min``, ``mins``, ``minute``, ``minutes``
     - Specify recent N minutes. For example, ``--since=-10m`` means within recent 10 minutes should be checked.
   * - ``h``, ``hour``, ``hours``
     - Specify recent N hours. For example, ``--since=-10h`` means within recent 10 hours should be checked.
   * - ``d``, ``day``, ``days``
     - Specify recent N days. For example, ``--since=-10d`` means within recent 10 days should be checked.
   * - ``w``, ``week``, ``weeks``
     - Specify recent N weeks. For example, ``--since=-10w`` means within recent 10 weeks should be checked.
   * - ``month``, ``months``
     - Specify recent N months. For example, ``--since=-10month`` means within recent 10 months should be checked.
   * - ``year``, ``years``
     - Specify recent N years. For example, ``--since=-1year`` means within recent 1 year should be checked.

``recover``
^^^^^^^^^^^

It recovers an existing broken Groonga database.

If the database is not broken, ``grndb`` does nothing and exits with
``0`` exit status.

If the database is broken and one or more index columns are only
broken, ``grndb`` recovers these index columns and exists with ``0``
exit status. It may take a long time for large indexed data.

If the database is broken and tables or data columns are broken,
``grndb`` reports broken reasons and exits with non-``0`` exit
status. You can know whether the database is recoverable or not by
``check`` command.

.. note::

   You must not use this command for opened database. If the database
   is opened, this command may break the database.

``recover`` has some options.

.. _grndb-force-truncate:

``--force-truncate``
""""""""""""""""""""

.. versionadded:: 7.0.4

It forces to truncate a corrupted database object.

Here is an example that specifies ``--force-truncate`` option::

  % grndb recover --force-truncate --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

When this option is specified, ``grndb`` does the followings:

* check whether there is a corrupted database object (table, column, indexes)
* truncate a corrupted database object (table, column, indexes)
* remove incremental files with .00N suffix which is created when large amount of data is loaded

``--force-truncate`` option is destructive one. Even though lock is still remained, ``grndb`` truncates a targeted corrupted database object.

After ``grndb recover`` command has finished, you need to load data
against truncated tables or columns to recreate database.

.. note::

   You must use this option only when necessary. It means that you use it when there is a mismatch between database meta information and database object files which exists actually. This options should be used when there is no other way to recover database.

.. _grndb-force-lock-clear:

``--force-lock-clear``
""""""""""""""""""""""

.. versionadded:: 7.1.1

It forces to clear lock of database, table and data column. It doesn't
clear lock of index column. If index column has lock, the index column
is recreated instead of clearing lock.

Normally, you should truncate and load data again instead of just
clearing lock. Because objects that have lock may be broken. This
option is provided only for users who know the risk that "the database
may be broken but I want to keep using it".

Here is an example that specifies ``--force-lock-clear`` option::

  % grndb recover --force-lock-clear --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

When this option is specified, ``grndb`` does the followings:

* check whether there are database, table or data column that have lock
* clear lock of these objects

.. note::

   You must use this option only when necessary. Because your database
   may not be recovered. The database that has objects that have lock
   may be broken or not be broken. You can keep using the database but
   Groonga may crash if the database is broken.

``--log-level``
"""""""""""""""

.. versionadded:: 7.0.4

It specifies a log level of ``grndb`` log.

Here is an example that specifies ``--log-level`` option::

  % grndb recover --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

See :doc:`/reference/commands/log_level` to know about supported log level.

``--log-path``
""""""""""""""

.. versionadded:: 7.0.4

It specifies a path of ``grndb`` log.

Here is an example that specifies ``--log-path`` option::

  % grndb recover --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db

``--log-flags``
"""""""""""""""

.. versionadded:: 9.0.2

It specifies a logged content in ``grndb`` log by flags.
The default value of ``--log-flags`` is ``time|message``. It means that timestamp and log messages are logged into ``grndb`` log.

Here is an example that specifies ``--log-flags`` option::

  % grndb check --log-path /var/log/groonga/grndb.log --log-flags "time|pid|message" /var/lib/groonga/db/db

See :doc:`groonga` to know about supported log flags.