Module xlog


Документация находится в процессе перевода и может отставать от английской версии.

Module xlog

The xlog module contains one function: pairs(). It can be used to read Tarantool’s snapshot files or write-ahead-log (WAL) files. A description of the file format is in section Data persistence and the WAL file format.


Open a file, and allow iterating over one file entry at a time.

Returns:iterator which can be used in a for/end loop.

Possible errors: File does not contain properly formatted snapshot or write-ahead-log information.


This will read the first write-ahead-log (WAL) file that was created in the wal_dir directory in our «Getting started» exercises.

Each result from pairs() is formatted with MsgPack so its structure can be specified with __serialize.

xlog = require('xlog')
t = {}
for k, v in xlog.pairs('00000000000000000000.xlog') do
  table.insert(t, setmetatable(v, { __serialize = "map"}))
return t

The first lines of the result will look like:

- - {'BODY':   {'space_id': 272, 'index_base': 1, 'key': ['max_id'],
                'tuple': [['+', 2, 1]]},
     'HEADER': {'type': 'UPDATE', 'timestamp': 1477846870.8541,
                'lsn': 1, 'server_id': 1}}
  - {'BODY':   {'space_id': 280,
                 'tuple': [512, 1, 'tester', 'memtx', 0, {}, []]},
     'HEADER': {'type': 'INSERT', 'timestamp': 1477846870.8597,
                'lsn': 2, 'server_id': 1}}