WAL extensions
WAL extensions available in Tarantool Enterprise Edition allow you to add auxiliary information to each write-ahead log record. For example, you can enable storing an old and new tuple for each CRUD operation performed. This information might be helpful for implementing a CDC (Change Data Capture) utility that transforms a data replication stream.
To configure WAL extensions, use the wal_ext
configuration property.
Inside the wal_ext
block, you can enable storing old and new tuples as follows:
Set the
old
andnew
options totrue
to store old and new tuples in a write-ahead log for all spaces.box.cfg { wal_ext = { old = true, new = true } }
To adjust these options for specific spaces, use the
spaces
option.box.cfg { wal_ext = { old = true, new = true, spaces = { space1 = { old = false }, space2 = { new = false } } } }
The configuration for specific spaces has priority over the global configuration, so only new tuples are added to the log for
space1
and only old tuples forspace2
.
Note that records with additional fields are replicated as follows:
- If a replica doesn’t support the extended format configured on a master, auxiliary fields are skipped.
- If a replica and master have different configurations for WAL records, a master’s configuration is ignored.
The table below demonstrates how write-ahead log records might look
for the specific CRUD operations
if storing old and new tuples is enabled for the bands
space.
Operation | Example | WAL information |
---|---|---|
insert | bands:insert{4, 'The Beatles', 1960} |
new_tuple: [4, ‘The Beatles’, 1960]
tuple: [4, ‘The Beatles’, 1960]
|
delete | bands:delete{4} |
key: [4]
old_tuple: [4, ‘The Beatles’, 1960]
|
update | bands:update({2}, {{'=', 2, 'Pink Floyd'}}) |
new_tuple: [2, ‘Pink Floyd’, 1965]
old_tuple: [2, ‘Scorpions’, 1965]
key: [2]
tuple: [[‘=’, 2, ‘Pink Floyd’]]
|
upsert | bands:upsert({2, 'Pink Floyd', 1965}, {{'=', 2, 'The Doors'}}) |
new_tuple: [2, ‘The Doors’, 1965]
old_tuple: [2, ‘Pink Floyd’, 1965]
operations: [[‘=’, 2, ‘The Doors’]]
tuple: [2, ‘Pink Floyd’, 1965]
|
replace | bands:replace{1, 'The Beatles', 1960} |
old_tuple: [1, ‘Roxette’, 1986]
new_tuple: [1, ‘The Beatles’, 1960]
tuple: [1, ‘The Beatles’, 1960]
|
Storing both old and new tuples is especially useful for the update
operation because a write-ahead log record contains only a key value.
Note
You can use the tt cat command to see the contents of a write-ahead log.