IF Commons GitHub

physical/merge

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0007-sql-merge FR-001, 0007-sql-merge FR-002, 0007-sql-merge FR-003, 0007-sql-merge FR-004

What the database does of merging: the rows of a path as the pure model's state (so that the winner, the heads and the next id are the model's, not a second reading of them), the version vector and the delta since one, the judgement of a delta (whom it is from, its checksums, its time, whether the database holds what its rows replace and the blobs its puts name, until it does the delta waits in the database) and its adding in one step, and the check of every row and blob a database holds, whatever way they came: this is the check of a database that rows were put into by a SQL import, in front of which no check of ours stood.

import { verifyDatabase } from "./merge.ts";
const findings = await verifyDatabase(port, ctx, Date.now());

Source: commons/anyfs-sql/src/physical/merge.ts

0 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Ctxtypeno test imports it
type Ctx = {
  readonly l: Layout;
  readonly replica: ReplicaId;
  readonly config: MergeConfig;
  readonly searching: boolean;
  readonly searchBytes: number;
};

What the merge needs of a store: the statements, who the replica is, what it is told that is not data, and whether the index of search is kept.

EpochRowtypeno test imports it
type EpochRow = { readonly n: number; readonly horizon: VersionVector; readonly roster: readonly ReplicaId[]; readonly retained: readonly string[]; readonly bound: string };

An epoch as the database holds it: how far the rows are collected (a horizon), against which roster, which covered rows it keeps (as keys) and the greatest id it collected.

Judgedtypeno test imports it
type Judged = { readonly outcome: MergeOutcome; readonly paths: readonly string[] };

What judging a delta ended with: the outcome, and the paths whose files it may have changed.

Takentypeno test imports it
type Taken = Judged;

What taking a delta ended with, and the paths whose files may have changed.

deltaOfDatabasefunctionno test imports it
function deltaOfDatabase(r: SqlRunner, c: Ctx, since: VersionVector): Promise<Delta>

The delta of what the database holds that a replica holding since does not: the rows past it and the blobs their puts name.

judgeDeltafunctionno test imports it
function judgeDelta(r: SqlRunner, c: Ctx, delta: Delta, wall: number): Promise<Judged>

Judges a delta and, where it is applied, adds its blobs and rows in the transaction the runner is: the trust, the checksums, the clock, whether the database holds what it needs. A delta that has to wait is kept in the database until what it waits for arrives.

stateOffunctionno test imports it
function stateOf(r: SqlRunner, c: Ctx, paths: readonly string[]): Promise<MergeState>

The state of the replica, as far as the paths it is given: their rows, and the clock and the number of the replica taken from every row the database holds.

takeDeltafunctionno test imports it
function takeDelta(r: SqlRunner, c: Ctx, delta: Delta, wall: number): Promise<Judged>

Takes a delta into the database. Where the delta is applied, the deltas held back are tried again, for what this one brought may be what they waited for; where it has to wait, it is kept in the database.

vectorOfDatabasefunctionno test imports it
function vectorOfDatabase(r: SqlRunner, c: Ctx): Promise<VersionVector>

The version vector of the database: for each replica, the number of its last row held with none missing before it. Where rows were collected, what an epoch covers counts as held, so the numbers start from its horizon: the rows above it are walked from there.

verifyDatabasefunctionno test imports it
function verifyDatabase(r: SqlRunner, c: Ctx, wall: number): Promise<readonly MergeFinding[]>

What is wrong with the rows and blobs the database holds, whatever way they came: a row that is not its checksum, an id that is not an id, a row of a replica the trust does not name, an id from the far future, an id or a number on two rows, a parent or a blob that is not there, bytes that are not the hash they are named by. This is the check of a database that rows were put into by a SQL import, in front of which no check of ours stood.

Titles, headings, exports, tables, columns and requirements. Esc closes.