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 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
|
.. -*- rst -*-
.. groonga-command
.. database: commands_io_flush
``io_flush``
============
Summary
-------
.. versionadded:: 5.0.5
``io_flush`` flushes all changes in memory to disk
explicitly. Normally, you don't need to use ``io_flush``
explicitly. Because flushing is done automatically by OS. And flushing
by OS is effective.
You need to use ``io_flush`` explicitly when your system may often
crash unexpectedly or you may not shutdown your Groonga process in a
normal way. (For example, using :doc:`shutdown` is a normal shutdown
process.) It's better that you use ``io_flush`` after you change your
Groonga database for the case. Here are commands that change your
Groonga database:
* :doc:`column_create`
* :doc:`column_remove`
* :doc:`column_rename`
* :doc:`delete`
* :doc:`load`
* :doc:`logical_table_remove`
* :doc:`object_remove`
* :doc:`plugin_register`
* :doc:`plugin_unregister`
* :doc:`table_create`
* :doc:`table_remove`
* :doc:`table_rename`
* :doc:`truncate`
If you're using :ref:`select-scorer` parameter in :doc:`select` to
change existing column values, :doc:`select` is added to the above
list.
Note that ``io_flush`` may be a heavy process. If there are many
changes in memory, flushing them to disk is a heavy process.
.. versionadded:: 8.0.8
``io_flush`` locks Groonga database while flushing. It means that
you can't run the following commands while ``io_flush``:
* :doc:`column_create`
* :doc:`column_remove`
* :doc:`column_rename`
* :doc:`logical_table_remove`
* :doc:`object_remove`
* :doc:`plugin_register`
* :doc:`plugin_unregister`
* :doc:`table_create`
* :doc:`table_remove`
* :doc:`table_rename`
Syntax
------
This command takes three parameters.
All parameters are optional::
io_flush [target_name=null]
[recursive=yes]
[only_opened=no]
.. versionadded:: 7.0.4
:ref:`io-flush-only-opened` is added.
.. versionadded:: 9.0.2
``--recursive dependent`` option is added. It is recommended way to flush
target object and its related objects since 9.0.2. See :ref:`io-flush-recursive` about details.
Usage
-----
You can flush all changes in memory to disk with no arguments:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/all.log
.. io_flush
If you know what is changed, you can narrow flush targets. Here is a
correspondence table between command and flush targets for Groonga 9.0.2 or later.
.. note:: There is a different recommended way which depends on Groonga version.
If Groonga is 9.0.1 or earlier ( ``--recursive dependent`` is not available ), you
need to flush related objects explicitly, otherwise, using ``--recursive dependent``
is a recommended way not to forget flush target objects.
.. list-table::
:header-rows: 1
* - Command
- Flush targets
- ``io_flush`` arguments
* - :doc:`load` and :doc:`delete`
- Target table and its columns.
If there are one or more reference columns in these columns,
referenced tables are also flush targets.
If there are one or more indexed columns in these columns,
tables of corresponding index columns and corresponding index
columns are also flush targets.
- Use ``--recursive dependent`` to flush target table and
its columns, referenced tables and tables of corresponding index columns
and corresponding index columns at once::
io_flush --target_name TABLE_NAME --recursive dependent
* - :doc:`truncate`
- Target table and its columns.
If there are one or more reference columns in these columns,
referenced tables are also flush targets.
If there are one or more indexed columns in these columns,
tables of corresponding index columns and corresponding index
columns are also flush targets.
Database is also flush target.
- Use ``--recursive dependent`` to flush target table and its columns,
referenced tables and tables of corresponding index columns and corresponding index
columns at once::
io_flush --target_name TABLE_NAME --recursive dependent
* - :doc:`table_create`
- Target table and database.
- Table::
io_flush --target_name TABLE_NAME --recursive dependent
* - :doc:`table_remove`, :doc:`table_rename` and :doc:`logical_table_remove`
- Database.
- Database::
io_flush --recursive no
* - :doc:`column_create`
- Target column and database.
- Table::
io_flush --target_name TABLE_NAME.COLUMN_NAME --recursive dependent
* - :doc:`column_remove` and :doc:`column_rename`
- Database.
- Database::
io_flush --recursive no
* - :doc:`plugin_register` and :doc:`plugin_unregister`
- Database.
- Database::
io_flush --recursive no
If Groonga is 9.0.1 or earlier ( ``--recursive dependent`` is not available ), flush
objects explicitly. Here is a correspondence table between command and flush targets
for Groonga 9.0.1 or earlier.
.. list-table::
:header-rows: 1
* - Command
- Flush targets
- ``io_flush`` arguments
* - :doc:`load` and :doc:`delete`
- Target table and its columns.
If there are one or more reference columns in these columns,
referenced tables are also flush targets.
If there are one or more indexed columns in these columns,
tables of corresponding index columns and corresponding index
columns are also flush targets.
- Table and its columns::
io_flush --target_name TABLE_NAME
A referenced table::
io_flush --target_name REFERENCED_TABLE_NAME --recursive no
A table of an index column::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN --recursive no
An index column::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN.INDEX_COLUMN
* - :doc:`truncate`
- Target table and its columns.
If there are one or more reference columns in these columns,
referenced tables are also flush targets.
If there are one or more indexed columns in these columns,
tables of corresponding index columns and corresponding index
columns are also flush targets.
Database is also flush target.
- Table and its columns::
io_flush --target_name TABLE_NAME
A referenced table::
io_flush --target_name REFERENCED_TABLE_NAME --recursive no
A table of an index column::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN --recursive no
An index column::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN.INDEX_COLUMN
Database::
io_flush --recursive no
* - :doc:`table_create`
- Target table and database.
- Table::
io_flush --target_name TABLE_NAME
Database::
io_flush --recursive no
* - :doc:`table_remove`, :doc:`table_rename` and :doc:`logical_table_remove`
- Database.
- Database::
io_flush --recursive no
* - :doc:`column_create`
- Target column and database.
- Table::
io_flush --target_name TABLE_NAME.COLUMN_NAME
Database::
io_flush --recursive no
* - :doc:`column_remove` and :doc:`column_rename`
- Database.
- Database::
io_flush --recursive no
* - :doc:`plugin_register` and :doc:`plugin_unregister`
- Database.
- Database::
io_flush --recursive no
Parameters
----------
This section describes all parameters.
Required parameters
^^^^^^^^^^^^^^^^^^^
There is no required parameter.
Optional parameters
^^^^^^^^^^^^^^^^^^^
There are optional parameters.
.. _io-flush-target-name:
``target_name``
"""""""""""""""
Specifies a target object name. Target object is one of database,
table or column.
If you omit this parameter, database is the target object:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/target_name_database.log
.. io_flush
If you specify a table name, the table is the target object:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/target_name_table.log
.. table_create Users TABLE_HASH_KEY ShortText
.. io_flush --target_name Users
If you specify a column name, the column is the target object:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/target_name_column.log
.. column_create Users age COLUMN_SCALAR UInt8
.. io_flush --target_name Users.age
.. _io-flush-recursive:
``recursive``
"""""""""""""
Specifies whether child objects of the target object are also target
objects.
Child objects of database are all tables and all columns.
Child objects of table are all its columns.
Child objects of column are nothing.
If you specify ``yes`` to :ref:`io-flush-only-opened`, ``recursive``
is ignored.
``recursive`` value must be ``yes``, ``no`` or ``dependent``. ``yes``
means that all of the specified target object and child objects are
the target objects. ``no`` means that only the specified target object
is the target object. ``dependent`` means that all of the specified
target object, child objects, corresponding table of index column and
corresponding index column are the target objects.
The following ``io_flush`` flushes all changes in database, all tables
and all columns:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/recursive_yes.log
.. io_flush --recursive yes
The following ``io_flush`` flushes all changes only in database:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/recursive_no.log
.. io_flush --recursive no
If you specify other value (not ``yes`` neither ``no``) or omit
``recursive`` parameter, ``yes`` is used.
``yes`` is used in the following case because invalid ``recursive``
argument is specified:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/recursive_invalid.log
.. io_flush --recursive invalid
``yes`` is used in the following case because ``recursive`` parameter
isn't specified:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/recursive_default.log
.. io_flush
Since 9.0.2, ``--recursive dependent`` is added to flush not only target object
and child objects, but also related objects. The related objects are:
* A referenced table
* A related index column (There is source column in target ``TABLE_NAME``)
* A table of related index column (There is source column in target ``TABLE_NAME``)
It is useful not to forget flushing related objects.
For example, ``--recursive dependent`` is specified for ``TABLE_NAME``, this
option executes equivalent to the following commands internally.
- Flush table and its columns::
io_flush --target_name TABLE_NAME --recursive yes
- Flush a referenced table::
io_flush --target_name REFERENCED_TABLE_NAME --recursive no
- Flush a related index column (There is source column in ``TABLE_NAME``)::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN.INDEX_COLUMN
- Flush a table of related index column (There is source column in ``TABLE_NAME``)::
io_flush --target_name TABLE_NAME_OF_INDEX_COLUMN --recursive no
To confirm whether all target objects are flushed correctly, you can check query log::
> io_flush --recursive "dependent" --target_name "Users"
:000000000000000 flush[Users]
:000000000000000 flush[Terms]
:000000000000000 flush[Terms.users_name]
:000000000000000 flush[Users.name]
:000000000000000 flush[(anonymous:table:dat_key)]
:000000000000000 flush[(anonymous:column:var_size)]
:000000000000000 flush[(anonymous:table:hash_key)]
:000000000000000 flush[(anonymous:column:var_size)]
:000000000000000 flush[(DB)]
<000000000000000 rc=0
In above example, specified not only ``Users`` table, related lexicon table ``Terms`` and
index column ``Terms.users_name`` (data source is ``Users.name``) are also flushed.
``flush[(anonymous:...)]`` and ``flush[(DB)]`` means that Groonga's internal objects
are also flushed.
.. list-table::
:header-rows: 1
* - Log
- Description
* - ``flush[(anonymous:table:dat_key)]``
- The internal object names in DB are flushed. If ``GRN_DB_KEY=pat`` is set, ``TABLE_PAT_KEY`` is used instead.
* - ``flush[(anonymous:column:var_size)]`` (logged as first ``(anonymous:column:var_size)`` object)
- The internal object metadata (builtin types, token filter and so on) are flushed.
This is a variable sized column which stores the above internal object metadata.
* - ``flush[(anonymous:table:hash_key)]``
- The internal configuration objects (which is set by ``config_set``) are flushed.
* - ``flush[(anonymous:column:var_size)]`` (logged as second ``(anonymous:column:var_size)`` object)
- The internal object metadata (options about internal objects such as specified tokenizer options) are flushed.
This is a variable sized column which stores the above internal object metadata.
* - ``flush[(DB)]``
- The DB changes (lock acquired during ``io_flush``) are flushed.
.. _io-flush-only-opened:
``only_opened``
"""""""""""""""
.. versionadded:: 7.0.4
Specifies whether opened objects are only flushed.
If there is only one process that changes the target database, flush
performance will be improved by specifying ``yes`` to
``only_opened``. It skips needless flushes.
You can't specify :ref:`io-flush-target-name` with ``only_opened``
option. If you specify :ref:`io-flush-target-name`, ``only_opened`` is
ignored.
If you specify ``yes`` to ``only_opened``, :ref:`io-flush-recursive`
is ignored.
``only_opened`` value must be ``yes`` or ``no``. ``yes`` means that
opened objects are only flushed. ``no`` means that all target objects
are flushed even they aren't opened.
The following ``io_flush`` flushes all changes in database, all tables
and all columns:
.. groonga-command
.. include:: ../../example/reference/commands/io_flush/only_opened_yes.log
.. io_flush --only_opened yes
Return value
------------
The command returns ``true`` as body on success such as::
[HEADER, true]
If the command fails, error details are in ``HEADER``.
See :doc:`/reference/command/output_format` for ``HEADER``.
|