Skip to main content

run_with_records

Function run_with_records 

Source
pub async fn run_with_records(
    args: FormatArgs,
    extra: Vec<MetadataRecord>,
) -> i32
Expand description

Formats the metadata log directory and args.log_dirs with extra seeded alongside the records the flags produce, returning the process exit code.

A cluster restored from tiered-storage archives has to come up with its topics already present, so the restore tool hands the topic and partition records it recovered to the formatter instead of repeating the bootstrap write itself. The extra records join the one seed stream, so they reach both the offset-zero checkpoint and the bootstrap files.

extra lands directly after the feature records and ahead of the --add-scram and --add-acl records. The finalized feature levels, metadata.version first, decide how every later record is read, so they lead the stream and a topic record can only come after them. Seeded topics ahead of seeded ACL entries then match the order a live cluster writes them in, where a topic exists before an entry names it as a resource. The KIP-853 control state – the KRaft version and the initial voters – is a separate stream that the checkpoint applies before any of these.

Ordering inside extra is the caller’s. A MetadataImage derives a topic’s partition count from the partition records that apply after it, so each TopicRecord must come before its own partitions.

§Panics

Panics if --initial-controllers was given without the node’s own identity appearing in it. is_dynamic_format rejects that combination before this point, so reaching the panic means that validation and this branch have drifted apart.