Narsil loads its indexes into memory, while an engine with a durability directory also writes them to disk so that the engine can load them again after a restart. With the durability tier, you choose how many writes the engine can lose in a crash. With an index setting, you choose whether the engine stores the text of an index in memory or loads it from the files of the index during each search.
On this page, you'll build store, a program that restarts an engine without losing its order index and then lists the files that a checkpoint writes. In the later sections, shorter programs measure the disk space that an index takes up, search an index larger than memory, close idle indexes, and move an index to another engine. Each code block below contains the whole file, with green lines marking the lines that you add at each step and struck lines marking the lines that you remove.
Recover every acknowledged write after a restart
With durability.directory set, the engine appends every insert, update, and removal to a write-ahead log in that directory before the call returns. The program writes three orders and shuts the engine down before it opens a second engine on the same directory.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { createNarsil } from '@delali/narsil'
const directory = await mkdtemp(join(tmpdir(), 'orders-'))
const first = await createNarsil({ durability: { directory } })
await first.createIndex('orders', { schema: { customer: 'string', item: 'string', total: 'number' } })
await first.insertBatch('orders', [
{ id: 'ord-1001', customer: 'first customer', item: 'Hydraulic disc brake set', total: 149 },
{ id: 'ord-1002', customer: 'second customer', item: 'Folding bicycle', total: 899 },
{ id: 'ord-1003', customer: 'third customer', item: 'Steel gravel frame', total: 1299 },
])
await first.shutdown()
const second = await createNarsil({ durability: { directory } })
console.log(JSON.stringify(second.listIndexes(), null, 2))
await second.shutdown()[
{
"name": "orders",
"documentCount": 3,
"partitionCount": 1,
"language": "english",
"state": "open",
"reopenCount": 0
}
]The second engine recovers the three orders from the directory before the call that creates it returns, so the orders are in the engine by the time of your first call after the restart. The second engine also recovers the configuration of each index, including its partition limits, so the engine refuses a createIndex call for a recovered name with INDEX_ALREADY_EXISTS. Only one engine at a time can write to a durability directory. When you open a second engine on a directory that another engine has open, the call fails with CONFIG_INVALID until the first engine shuts down.
Choose how many writes you can lose in a crash
In a test of the TypeScript engine 0.4.6, a child process writes 500 orders one at a time and then kills itself with SIGKILL. The test then opens a fresh engine with the same configuration and counts the orders that the engine recovers from the directory of the child process:
| Configuration | Tier | Orders recovered |
|---|---|---|
durability.directory with mode: 'sync' | Write-ahead log | 500 of 500 |
durability.directory with mode: 'async' | Write-ahead log | 500 of 500 |
A persistence adapter with durability.tier: 'snapshot' and no checkpoint | Snapshot | 0 of 500 |
Under sync, which is the default, the engine forces each write to disk before the call returns. Under async, the engine acknowledges each write at once and forces the log to disk every flushIntervalMs. When the test kills the process under async, the engine loses no writes, although the engine can lose the writes from the last interval in a power cut or a crash of the operating system. On the snapshot tier, the engine writes no log and saves each changed partition whole at each checkpoint, so the engine can lose every write since the last checkpoint in a crash.
Use the durability block to tune the log and the checkpoint schedule. flushIntervalMs is 1,000 by default. By default, the engine also takes a checkpoint every 300,000 ms or after 100,000 changes, whichever comes first. The engine starts a new log segment once the current one reaches segmentMaxBytes, which is 64 MiB by default. It merges the segment files of a partition once the partition has more than compactionThreshold of them, which is 12 by default. In this step, the program also forces a checkpoint and lists the files under the index.
import { mkdtemp } from 'node:fs/promises'
import { mkdtemp, readdir } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { createNarsil } from '@delali/narsil'
const directory = await mkdtemp(join(tmpdir(), 'orders-'))
const durability = {
directory,
mode: 'async',
flushIntervalMs: 250,
checkpointIntervalMs: 60_000,
checkpointMutationThreshold: 10_000,
} as const
const first = await createNarsil({ durability: { directory } })
const first = await createNarsil({ durability })
await first.createIndex('orders', { schema: { customer: 'string', item: 'string', total: 'number' } })
await first.insertBatch('orders', [
{ id: 'ord-1001', customer: 'first customer', item: 'Hydraulic disc brake set', total: 149 },
{ id: 'ord-1002', customer: 'second customer', item: 'Folding bicycle', total: 899 },
{ id: 'ord-1003', customer: 'third customer', item: 'Steel gravel frame', total: 1299 },
])
await first.checkpoint('orders')
await first.shutdown()
const second = await createNarsil({ durability: { directory } })
const second = await createNarsil({ durability })
console.log(JSON.stringify(second.listIndexes(), null, 2))
console.log(JSON.stringify((await readdir(join(directory, 'orders'), { recursive: true })).sort(), null, 2))
await second.shutdown()[
"manifest",
"meta",
"segments",
"segments/0",
"segments/0/s0000000000000000",
"wal",
"wal/0",
"wal/0/0000000000000004",
"wal/0/commit"
]All four engines write the same files, because they use one file format. Each index has a manifest, a meta file, and one folder for each partition under segments and under wal. At each checkpoint, the engine writes new segment files for each changed partition and deletes the log segments that the checkpoint covers. The engine then opens a fresh log segment, so after a restart the engine replays only the writes since that checkpoint. The commit file contains the point up to which the engine forces the log to disk.
The engine reports a failed write to the durability directory through the durabilityError event, so register a handler for it, as in the examples on the Observability page. When the directory of an open engine goes missing, or when its path leads to another directory, the engine fails every later write with PERSISTENCE_SAVE_FAILED. When the filesystem refuses a checkpoint, such as one into a read-only folder, the engine fails the checkpoint and every later write with the same code.
See how much disk an index takes
In every engine, getStats and getPartitionStats report two sizes for an index that the engine saves to disk. savedBytes is the size of the files in the latest checkpoint of the index. logBytes is the size of the write-ahead log, along with the size of the history that the engine retains for device sync. In the Rust crate, the two sizes are saved_bytes and log_bytes, while the Go module returns each one as an Optional[int64]. Each program sets the checkpoint interval to 0, which turns the automatic checkpoint off so that each figure changes only when the program calls checkpoint. The setting is checkpointIntervalMs in TypeScript and Python, CheckpointInterval in Go, and checkpoint_interval_ms in Rust.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { createNarsil } from '@delali/narsil'
const narsil = await createNarsil({
durability: { directory: await mkdtemp(join(tmpdir(), 'support-desk-')), checkpointIntervalMs: 0 },
})
const sizes = (): { savedBytes?: number; logBytes?: number } => {
const { savedBytes, logBytes } = narsil.getStats('tickets')
return { savedBytes, logBytes }
}
await narsil.createIndex('tickets', { schema: { subject: 'string', priority: 'enum' } })
await narsil.insertBatch(
'tickets',
Array.from({ length: 2_500 }, (_unused, position) => ({
id: `ticket-${position}`,
subject: `Refund request ${position}`,
priority: position % 3 === 0 ? 'high' : 'low',
}))
)
const afterInserts = sizes()
await narsil.checkpoint('tickets')
console.log(JSON.stringify({ afterInserts, afterCheckpoint: sizes() }, null, 2))
await narsil.shutdown(){
"afterInserts": {
"savedBytes": 0,
"logBytes": 454628
},
"afterCheckpoint": {
"savedBytes": 407022,
"logBytes": 8
}
}Before the checkpoint, the 2,500 tickets exist only in the log, which takes up 454,628 bytes, or 454,630 bytes in Go. At the checkpoint, the engine writes the tickets into segment files of 407,022 bytes and deletes the log segment that the checkpoint covers, so the log consists of one empty 8-byte segment. savedBytes changes only when a checkpoint commits, so the engine reports the same figure for an unchanged index before and after a restart. For that reason, savedBytes is the figure that you can bill on or alert on. For a closed index, the engine reports the savedBytes from its last checkpoint and no logBytes. For an index on the snapshot tier, the engine reports only savedBytes, because the engine writes no log on that tier.
Drop removed documents from the files
After a removal or an update, the old copy of a document is in its segment file until the engine writes that segment again at a checkpoint. At every checkpoint, the engine works out what share of the documents in the segment files of each partition are copies that a later removal or update replaces. Once that share passes 0.2, the engine rewrites the segments whose rewrite frees the most bytes and drops the old copies as it writes them. In this step, the program removes 1,000 of the 2,500 tickets, which is a share of 0.4, and then takes one more checkpoint.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { createNarsil } from '@delali/narsil'
const narsil = await createNarsil({
durability: { directory: await mkdtemp(join(tmpdir(), 'support-desk-')), checkpointIntervalMs: 0 },
})
const sizes = (): { savedBytes?: number; logBytes?: number } => {
const { savedBytes, logBytes } = narsil.getStats('tickets')
return { savedBytes, logBytes }
}
await narsil.createIndex('tickets', { schema: { subject: 'string', priority: 'enum' } })
await narsil.insertBatch(
'tickets',
Array.from({ length: 2_500 }, (_unused, position) => ({
id: `ticket-${position}`,
subject: `Refund request ${position}`,
priority: position % 3 === 0 ? 'high' : 'low',
}))
)
const afterInserts = sizes()
await narsil.checkpoint('tickets')
console.log(JSON.stringify({ afterInserts, afterCheckpoint: sizes() }, null, 2))
const afterCheckpoint = sizes()
await narsil.removeBatch('tickets', Array.from({ length: 1_000 }, (_unused, position) => `ticket-${position}`))
const afterRemovals = sizes()
await narsil.checkpoint('tickets')
console.log(JSON.stringify({ afterInserts, afterCheckpoint, afterRemovals, afterRewrite: sizes() }, null, 2))
await narsil.shutdown(){
"afterInserts": {
"savedBytes": 0,
"logBytes": 454628
},
"afterCheckpoint": {
"savedBytes": 407022,
"logBytes": 8
},
"afterRemovals": {
"savedBytes": 407022,
"logBytes": 124898
},
"afterRewrite": {
"savedBytes": 247128,
"logBytes": 8
}
}After the removals, savedBytes is unchanged while the engine adds their records to the log, because the old copies are in the segment files until the next checkpoint. At the next checkpoint, the engine rewrites the files without the removed tickets, so savedBytes falls by 39% in TypeScript and Go and by 37% in Python and Rust.
At a checkpoint, the engine spends one budget on these rewrites across all the partitions. You set that budget with durability.rewriteBytesPerCheckpoint, which is RewriteBytesPerCheckpoint in the Go module and rewrite_bytes_per_checkpoint in the Rust crate. The budget is a whole number of bytes of at least 1, with a default of 268,435,456 bytes, or 256 MiB. Even after the engine spends the budget, it rewrites one segment in every partition above 0.2. The files of each such partition therefore shrink at every checkpoint, while the engine spreads the rewrites for a large removal across the checkpoints that follow. On the snapshot tier, the engine accepts the setting and ignores it, because the engine writes each changed partition whole on that tier. The engine goes on rewriting at each automatic checkpoint until the share falls to 0.2 or below, so savedBytes falls after a large removal without any further write. With the automatic checkpoint off, as here, the engine defers the rewrites until the next checkpoint call or until the number of changes reaches checkpointMutationThreshold.
The engine needs free disk space for a rewrite, because it writes every new file of a checkpoint before it deletes an old one. Plan for extra space of up to the budget, plus the largest segment of each partition above 0.2. With the default budget and 16 such partitions whose largest segments are 64 MiB each, the engine can write 256 MiB + 16 × 64 MiB = 1,280 MiB of new files at a checkpoint before it deletes the old ones. The engine deletes a replaced file at the next checkpoint, once every worker reads from the new files, so the old files take up disk space for one more checkpoint interval. When the process crashes during a rewrite, the engine recovers from the previous checkpoint, because it commits a checkpoint by writing its manifest last.
Search an index larger than memory
With textStorage: 'disk' on an index, the engine searches the documents that a checkpoint covers in the segment files, which means that the engine loads those documents from the files only when a search requires them. Every engine accepts the setting, although an engine without a durability directory refuses it with CONFIG_INVALID. The program creates the same 20,000 tickets in an index of each kind and then compares the memory estimates of the engine after a checkpoint.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { createNarsil } from '@delali/narsil'
const TICKET_COUNT = 20_000
const PRODUCTS = ['card reader', 'receipt printer', 'cash drawer', 'barcode scanner'] as const
const narsil = await createNarsil({
durability: { directory: await mkdtemp(join(tmpdir(), 'support-archive-')) },
})
const tickets = Array.from({ length: TICKET_COUNT }, (_unused, position) => ({
id: `ticket-${position}`,
subject: `The ${PRODUCTS[position % PRODUCTS.length]} stopped responding at store ${position % 400}`,
body: `A shop assistant reported that the ${PRODUCTS[position % PRODUCTS.length]} lost its connection and came back after a restart. Ticket ${position} lists the steps that the assistant tried before calling support.`,
}))
const report: Record<string, { estimatedMemoryBytes: number; matches: number }> = {}
for (const textStorage of ['memory', 'disk'] as const) {
const name = `tickets-${textStorage}`
await narsil.createIndex(name, { schema: { subject: 'string', body: 'string' }, textStorage })
await narsil.insertBatch(name, tickets)
await narsil.checkpoint(name)
const { count } = await narsil.query(name, { term: 'receipt printer', termMatch: 'all', limit: 0 })
report[textStorage] = { estimatedMemoryBytes: narsil.getStats(name).estimatedMemoryBytes, matches: count }
}
console.log(JSON.stringify(report, null, 2))
await narsil.shutdown(){
"memory": {
"estimatedMemoryBytes": 14373451,
"matches": 5000
},
"disk": {
"estimatedMemoryBytes": 2558034,
"matches": 5000
}
}The engine finds the same 5,000 tickets in both indexes, while its memory estimate for the disk index is 18% of the estimate for the memory index in TypeScript, 11% in Go, and 8% in Python and Rust. Until the next checkpoint, the engine stores each new write in memory and in the log, as it does for any index. After you load an index, wait for a checkpoint before you measure its memory. After a restart, the engine loads the resident sections of each segment and replays the part of the log after the checkpoint, before it answers searches from the files.
The engine gives each thread that searches a read cache of up to 128 MiB. The engine counts the cache of the main thread in the memory estimate of the index, while in TypeScript, getMemoryStats counts the cache of each worker in the external figure for that worker. The engine therefore measures lifecycle.maxOpenBytes against the memory that the index uses on the main thread alone, however large its files grow. The engine checks each block of a file against its checksum the first time that it loads the block. The engine refuses a damaged block with PERSISTENCE_CRC_MISMATCH, so the engine answers searches only from blocks that pass the check.
Close the indexes that you are not using
An engine with durability can release an index from memory and load it again for the next call on that index. close(indexName) releases one index, while open(indexName) loads it again. In Python and Rust, the methods are called close_index and open_index. With lifecycle, the engine releases indexes for you in three ways:
- It closes an index after
idleTimeoutMswithout a read or a write. - It closes the least recently used index whenever more than
maxOpenIndexesindexes are open. - It closes the least recently used indexes whenever its memory estimate for the open indexes passes
maxOpenBytes.
In TypeScript, close fails with CONFIG_INVALID on an engine without durability, because the engine has no files from which it can load the index again.
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { setTimeout as sleep } from 'node:timers/promises'
import { createNarsil } from '@delali/narsil'
const narsil = await createNarsil({
durability: { directory: await mkdtemp(join(tmpdir(), 'help-desk-')) },
lifecycle: { maxOpenIndexes: 2, idleTimeoutMs: 400 },
})
const count = (state: string): number => narsil.listIndexes().filter((index) => index.state === state).length
for (const name of ['orders', 'invoices', 'shipments']) {
await narsil.createIndex(name, { schema: { customer: 'string', total: 'number' } })
await narsil.insert(name, { id: `${name}-1`, customer: 'first customer', total: 149 })
}
const afterCreating = { open: count('open'), closed: count('closed') }
const closedIndex = narsil.listIndexes().find((index) => index.state === 'closed')
if (closedIndex === undefined) throw new Error('The engine closed no index')
await narsil.query(closedIndex.name, { term: 'first customer' })
const reopened = narsil.listIndexes().find((index) => index.name === closedIndex.name)
const afterReopening = { open: count('open'), closed: count('closed'), reopenCount: reopened?.reopenCount }
await sleep(1_200)
const afterIdling = { open: count('open'), closed: count('closed') }
console.log(JSON.stringify({ afterCreating, afterReopening, afterIdling }, null, 2))
await narsil.shutdown(){
"afterCreating": {
"open": 2,
"closed": 1
},
"afterReopening": {
"open": 2,
"closed": 1,
"reopenCount": 1
},
"afterIdling": {
"open": 0,
"closed": 3
}
}When you create the third index, the engine closes the index with the longest time since its last call, so two of the three indexes are open. The program then queries the closed index, which the engine loads again with a reopenCount of 1. The engine then closes the least recently used of the other two indexes so that the number of open indexes goes back to maxOpenIndexes. The TypeScript, Python, and Rust engines record the last call on each index to the millisecond, so when the last calls on two indexes fall in the same millisecond, the engine can close either of them. The program therefore looks up the closed index by its state and prints how many indexes are open, a count that is the same every time the program executes. By 1,200 ms without a call, all three indexes are closed, because each one is past its idleTimeoutMs of 400. A closed index appears in listIndexes as well, with the document count from its last checkpoint. The engine answers listIndexes, getStats, and getMemoryStats without loading the index.
When a reopen fails, the engine leaves the index closed and tries again on a later call. The engine waits 100 ms after the first failure, and twice as long after each failure that follows. After the fifth failure, the engine marks the index as reopen-failed and answers every call on the index with the stored error until a call to open clears that state.
Share one directory between processes
The TypeScript package is the only package with invalidation adapters, so this section covers TypeScript alone. On the write-ahead-log tier, each engine needs a separate directory, so set the snapshot tier on every process that shares one store. On that tier, an invalidation adapter publishes each change so that every other process can reload the partitions that contain the changed documents. createNarsil throws CONFIG_INVALID for an invalidation adapter on the write-ahead-log tier, so give every process that shares the directory this configuration.
import { createNarsil } from '@delali/narsil'
import { createFilesystemPersistence } from '@delali/narsil/adapters/filesystem'
import { createFilesystemInvalidation } from '@delali/narsil/invalidation/filesystem'
const narsil = await createNarsil({
persistence: createFilesystemPersistence({ directory: './narsil-shared' }),
invalidation: createFilesystemInvalidation({ directory: './narsil-shared' }),
durability: { tier: 'snapshot' },
})
await narsil.shutdown()On the snapshot tier, the engine takes no checkpoint when you call shutdown(), so call checkpoint(indexName) before a planned stop. Subscribe to invalidationError in every process, because the engine reports a failed publish or reload only through that event.
Move an index as a snapshot
snapshot(indexName) writes the index into one archive, which is a pax file that contains the configuration of the index, the manifest of one checkpoint, and every file that the manifest lists. restore(indexName, archive) creates an index from that archive under the name that you pass, replacing any existing index of that name. The program writes the archive to a file and then restores it under a second name.
import { createReadStream, createWriteStream } from 'node:fs'
import { mkdtemp } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Writable } from 'node:stream'
import { createNarsil } from '@delali/narsil'
const folder = await mkdtemp(join(tmpdir(), 'orders-backup-'))
const narsil = await createNarsil()
await narsil.createIndex('orders', { schema: { customer: 'string', item: 'string', total: 'number' } })
await narsil.insertBatch('orders', [
{ id: 'ord-1001', customer: 'first customer', item: 'Hydraulic disc brake set', total: 149 },
{ id: 'ord-1002', customer: 'second customer', item: 'Folding bicycle', total: 899 },
{ id: 'ord-1003', customer: 'third customer', item: 'Steel gravel frame', total: 1299 },
])
const archive = join(folder, 'orders.tar')
await (await narsil.snapshot('orders')).pipeTo(Writable.toWeb(createWriteStream(archive)))
await narsil.restore('orders-copy', createReadStream(archive))
const found = await narsil.query('orders-copy', { term: 'gravel' })
console.log(
JSON.stringify(
{ copied: await narsil.countDocuments('orders-copy'), found: found.hits.map((hit) => hit.id) },
null,
2
)
)
await narsil.shutdown(){
"copied": 3,
"found": [
"ord-1003"
]
}The restored copy contains all three orders, so the same search on it returns the same results. The archive format has a published specification, so you can restore an archive in another process, on another machine, or with the engine for another language. For example, the Python package restores an archive from the TypeScript engine with every document in place. With write-ahead-log durability, the engine takes a checkpoint before it writes the archive, so the archive contains every write that the engine acknowledges before the call.
The engine checks the length and the checksum of each file in the archive before it loads the files into a separate index. The engine goes on answering from the existing index until it has loaded the restored index in full, at which point it swaps the restored index in. When a check or the load fails, the engine raises PERSISTENCE_LOAD_FAILED or PERSISTENCE_CRC_MISMATCH and leaves the existing index in place. restore also accepts the single .nrsl file that snapshot returns in release 0.3. The engine loads such a file by inserting its documents as new writes.
Move documents into a new release with an export
exportDocuments(indexName) writes the index as JSON Lines text, which starts with a header line that contains the format name, the format version, and the index configuration, followed by one line for each document. The export format is the same in every release, so you can use an export to move an index across several releases or between engines. You can also edit the header and the documents of an export to move them into a new schema. importDocumentExport(indexName, lines), which is import_documents in Python and Rust, creates the index from the header when no index has that name. When the index exists, the engine writes into it if every field has the same type as in the header. If a type differs, the engine raises CONFIG_INVALID before it writes anything.
import { createReadStream, createWriteStream } from 'node:fs'
import { mkdtemp } from 'node:fs/promises'
import { mkdtemp, readFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { Writable } from 'node:stream'
import { createNarsil } from '@delali/narsil'
const folder = await mkdtemp(join(tmpdir(), 'orders-backup-'))
const narsil = await createNarsil()
await narsil.createIndex('orders', { schema: { customer: 'string', item: 'string', total: 'number' } })
await narsil.insertBatch('orders', [
{ id: 'ord-1001', customer: 'first customer', item: 'Hydraulic disc brake set', total: 149 },
{ id: 'ord-1002', customer: 'second customer', item: 'Folding bicycle', total: 899 },
{ id: 'ord-1003', customer: 'third customer', item: 'Steel gravel frame', total: 1299 },
])
const archive = join(folder, 'orders.tar')
await (await narsil.snapshot('orders')).pipeTo(Writable.toWeb(createWriteStream(archive)))
await narsil.restore('orders-copy', createReadStream(archive))
const found = await narsil.query('orders-copy', { term: 'gravel' })
const lines = join(folder, 'orders.jsonl')
await (await narsil.exportDocuments('orders')).pipeTo(Writable.toWeb(createWriteStream(lines)))
const imported = await narsil.importDocumentExport('orders-next', createReadStream(lines))
console.log(
JSON.stringify(
{ copied: await narsil.countDocuments('orders-copy'), found: found.hits.map((hit) => hit.id) },
null,
2
)
)
console.log((await readFile(lines, 'utf8')).split('\n').slice(0, 2).join('\n'))
console.log(JSON.stringify(imported))
await narsil.shutdown(){
"copied": 3,
"found": [
"ord-1003"
]
}
{"format":"narsil-export","version":1,"index":{"schema":{"customer":"string","item":"string","total":"number"},"language":"english","analysisRevision":"4026533016c7f4b1","arrayPositionGap":100,"surfaceForms":true}}
{"id":"ord-1001","customer":"first customer","item":"Hydraulic disc brake set","total":149}
{"imported":3,"refusedCount":0,"refused":[]}All four engines write the same header and the same document lines. During an import, the engine writes the documents in batches of 1,000 and replaces any document whose id the index contains, so you can repeat an interrupted import to make the index equal to the export. When a line is invalid or the engine refuses its document, the engine records the refusal and moves on to the next line. refused contains the first 1,000 refusals, in line-number order. JSON has no type for a date, raw bytes, or an infinite number, so the engine exports each such value as a tag such as {"$date":[1700000000,123000000]}, which the engine turns back into the original value on import.
When the engine opens an index in the layout of release 0.3, it rewrites the index in the current layout before it answers the first call on that index. The engine emits layoutUpgrade as each rewrite starts, completes, or fails. Without lifecycle settings, the engine rewrites every such index before createNarsil resolves, which means that the engine emits those events before you can register a handler with on. For that reason, pass the handler in the events setting of createNarsil. The engine refuses an index from before release 0.3 with ENVELOPE_VERSION_MISMATCH. From release 0.4 onwards, you can move an index into a new release when you export it with the release in use and then import the export into the new release.
Where to go next
- Read Partitions and workers for the partitions, each of which has a folder in the durability directory, and for the worker copies that load the segment files.
- Read Observability for the events through which the engine reports a failed write to the durability directory.
- Read HTTP server for the routes with which a client can take and restore snapshots, and export and import documents, through a server.