# Log

For each vnode in the ring, there exists one log file.

Currently the log is used for 3 things:

* Loading the state of objects into the materialiser on restart (done by replaying the log).
* Resending lost updates to external DCs.
* Reading an older version of an object than what is available in memory.

Each log entry is defined by the following records:

```erlang
-type log_operation() :: #log_operation{}.
-record(log_operation, {
    tx_id :: txid(),
    op_type :: update
             | prepare
             | commit
             | abort
             | noop,
    log_payload :: any_log_payload()
}).


-type any_log_payload() :: #update_log_payload{}
                         | #commit_log_payload{}
                         | #abort_log_payload{}
                         | #prepare_log_payload{}.
-type commit_log_payload() :: #commit_log_payload{}.
-type update_log_payload() :: #update_log_payload{}.
-type op_number() :: #op_number{}.
-type op_name() :: atom().
-type op_param() :: term().
-type op() :: {op_name(), op_param()}.


-record(commit_log_payload, {
    commit_time :: dc_and_commit_time(),
    snapshot_time :: snapshot_time()
}).

-record(update_log_payload, {
    key :: key(),
    bucket :: bucket(),
    type :: type(),
    op :: op()
}).

-record(abort_log_payload, {}).

-record(prepare_log_payload, {prepare_time :: non_neg_integer()}).

-record(op_number, {
    node :: undefined | {node(), dcid()},
    global :: undefined | non_neg_integer(),
    local :: undefined | non_neg_integer()
}).
```

![](/files/-LteiKvmC_aHlLWNxF7Z)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://antidotedb.gitbook.io/documentation/architecture/log.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
