Pipeline.execute reports every attempt it starts and finishes, and every
step it skips, to a Store; a step's reads and commits reach the same store
through the Recorder its Ctx holds. MemoryStore keeps them in the
process, for a run that lives as long as it does; orca.state.PgStore
writes them to Postgres, so a run can be resumed by another process.
RunStore is a Store that also keeps runs: the rest of what a pipeline
binary (orca.cli) asks of persistence, from registering the pipeline to
ending its run, so the binary depends on this trait and nothing else.
The scheduler and the UI query orca.state.State's SQL directly.
Structs
StepRun
struct StepRun
One step for one partition (or for the run, for a gather step).
Implements Copyable, Movable
- Fields
step: Stringpartition: String: Empty for a gather step.status: Stringoutput: List[UInt8]: The encoded output, when the step succeeded.error: Stringattempt: Int: The number of the attempt that settled it; 0 for a skipped step.until: Int64: When a deferred step may run again, on orca.civil.now's clock.
__init__
def __init__(out self, step: String, partition: String, status: String, var output: List[UInt8], error: String, attempt: Int = Int(0), until: Int64 = Int64(0))
RunResult
struct RunResult
What a run did: every step and partition, in the order they ran.
Implements Movable
- Fields
steps: List[StepRun]
succeeded
def succeeded(self) -> Bool
deferred_until
def deferred_until(self) -> Int64
When the run may go on, if a step deferred and none failed: the latest time its deferred steps asked for. 0 otherwise.
outcome
def outcome(self) -> String
succeeded, deferred or failed.
find
def find(self, step: StringSpan, partition: StringSpan) -> Int
The index of step for partition, or -1.
status
def status(self, step: StringSpan, partition: StringSpan) -> String
output
def output[T: Movable](self, step: StringSpan, partition: StringSpan = "") -> T
The decoded output of step for partition.
Backoff
struct Backoff
The waits between retries of one write to a store.
again(e) is called with what the write raised: it raises again if the
error is final (FINAL) or the time (db_retry_seconds) is up, else
it waits, a quarter of a second doubling to 4 s; the store then
reconnects and tries again.
Implements Movable
- Fields
what: String: The store, for the message: Postgres, SQLite.started: Intwait: Float64budget: Float64
__init__
def __init__(out self, what: String)
again
def again(mut self, e: Error)
RunInfo
struct RunInfo
Implements Copyable, Movable
- Fields
id: Intpipeline: Stringregistry_hash: Stringpartitions: Stringstatus: Stringowner: Stringerror: String: Why the run ended without its steps saying so, or empty.
Usage
struct Usage
What an attempt's processes used (orca.usage): the peak resident bytes of its process tree, its CPU seconds, and the most cores it kept busy over a sample's interval. Each is -1 where it isn't known: a run on EC2 or Kubernetes, one no scheduler or worker started, or on macOS the peak cores, which only samples give.
Implements Copyable, ImplicitlyCopyable, Movable
- Fields
peak_rss_bytes: Intcpu_seconds: Float64peak_cpus: Float64
StepInfo
struct StepInfo
Implements Copyable, Movable
- Fields
step: Stringpartition: Stringstatus: Stringattempts: Interror: Stringlog: String: The latest attempt's log file, or empty.usage: Usage: What the latest attempt used, as far as it's known.
TableSnapshot
struct TableSnapshot
A table, by its location, at a snapshot.
Implements Copyable, Movable
- Fields
table: Stringsnapshot_id: Int64: -1 for a table that had no snapshot yet.dataset: String: The table's dataset name, namespace.table, or empty for a table outside the warehouse.
Recorder
struct Recorder
Records an attempt's reads and commits in the store it came from, as they happen, so a process killed right after a commit still leaves it on record.
It holds the store by address, as Ctx holds the run's dista runtime:
Ctx isn't generic over the store, and the store outlives every Ctx
Pipeline.execute makes from it.
Implements Movable
__init__
def __init__(out self)
A recorder that records nothing.
def __init__[S: Store](out self, mut store: S)
A recorder that records in store.
fence
def fence(mut self)
Raises unless this process may still commit for its run: what orca.tables checks right before each commit (Store.fence).
read
def read(mut self, t: TableSnapshot)
commit
def commit(mut self, t: TableSnapshot)
MemRecord
struct MemRecord
A read or commit an attempt recorded in a MemoryStore.
Implements Copyable, Movable
- Fields
attempt: Int: The attempt's index in the store's attempts.commit: Booltable: TableSnapshot
MemoryStore
struct MemoryStore
Keeps runs in the process's memory: what <pipeline> run uses without ORCA_DATABASE_URL, and Pipeline.run.
The same rows PgStore keeps, and the same rules: a run in it can be
interrupted, claimed by another owner and resumed, so long as the
process lives. Its runs are numbered 0, -1, -2, ...: never positive, so
Ctx.made recognises none of their commits, since another process's
in-memory run would have the same number. Nothing beats the heartbeat:
no other process can see the run.
Implements Movable, RunStore, Store
- Fields
records: List[MemRecord]: Every read and commit recorded, in order.run: Intowner: Stringregistry_hash: String
request_cancel
def request_cancel(mut self, run: Int)
Asks run to cancel, as orca ui does in Postgres.
register
def register(mut self, pipeline: String, registry_hash: String, describe: String)
scheduled_hash
def scheduled_hash(mut self, pipeline: String) -> String
version
def version(mut self, pipeline: String, registry_hash: String, describe: String, image: String) -> Int
create_run
def create_run(mut self, pipeline: String, registry_hash: String, partitions: String, trigger: String, owner: String) -> Int
claim
def claim(mut self, run: Int, owner: String, stale_seconds: Float64)
ran_version
def ran_version(mut self, run: Int, version: Int)
interrupt
def interrupt(mut self, run: Int, why: String = "") -> Int
prior
def prior(mut self, run: Int) -> RunResult
run_info
def run_info(mut self, run: Int) -> RunInfo
runs
def runs(mut self, limit: Int, before: Int = Int(0), status: String = "") -> List[RunInfo]
steps
def steps(mut self, run: Int) -> List[StepInfo]
own
def own(mut self, run: Int, owner: String, registry_hash: String)
start_heartbeat
def start_heartbeat(mut self, interval: Float64, timeouts: String = "")
stop_heartbeat
def stop_heartbeat(mut self)
finish_run
def finish_run(mut self, status: String)
defer_run
def defer_run(mut self, until: Int64)
cancel_requested
def cancel_requested(mut self) -> Bool
start_attempt
def start_attempt(mut self, step: String, partition: String, ord: Int, input: Span[UInt8]) -> Int
finish_attempt
def finish_attempt(mut self, step: String, partition: String, attempt: Int, status: String, output: Span[UInt8], error: String)
skip
def skip(mut self, step: String, partition: String, ord: Int, reason: String)
pinned_reads
def pinned_reads(mut self, step: String, partition: String) -> Dict[String, Int64]
record
def record(mut self, commit: Bool, t: TableSnapshot)
set_log
def set_log(mut self, step: String, partition: String, attempt: Int, path: String)