Error Handling and Diagnostics#
Check synchronous return values immediately. For asynchronous calls, check both submission and completion. A successful submission does not mean the operation succeeded.
Checking Errors#
Python raises ovstage.OvstageError for stage errors and
ovstage.OvxError for path-dictionary errors. Both derive from RuntimeError
and carry a numeric code and a message. Some invalid Python arguments raise TypeError or ValueError
before calling the native API. On success, wait() returns the operation or
handle it was called on.
For Python calls that return an operation or query/read/map handle, call wait() even if submission did not raise. The returned object can carry a rejected native submission. For example, Stage.query() returns a Query for an unsupported filter; query.wait() raises OvstageError with code ErrorCode.NOT_SUPPORTED.
In C, check the status returned by the call. After ovstage_wait_op(),
also inspect every operation ID in error_op_ids. Retrieve its message
before the next wait on the same thread, which invalidates the list and messages.
Release operation tracking only after reading the diagnostics.
The boundary where a failure is discovered affects its reported code. A rejected
enqueue can return a specific status such as WRITE_FLOOR_VIOLATION or
OUT_OF_RANGE directly. For an accepted operation that fails during execution,
wait_op and mutation wait() generally report OP_FAILED; inspect the
diagnostic for the underlying reason.
Reads can validate an already-ready query at enqueue, or defer validation until
their producer runs. A fetch that waits for a failed producer can report
OP_FAILED; a fetch after that producer has completed can expose its specific
recorded status. Resolve the query first when using OUT_OF_RANGE to choose
a current-state fallback, and still handle deferred producer failures.
The snippets below show Python catching a failed write and the C++ helper used by the C examples to wait, check errors, and release operation tracking.
# wait() reports rejected submissions and failed operations or dependencies.
# OvstageError carries a numeric code and a message.
def write_checked(stage, query, attr, ordinal, values) -> bool:
try:
stage.write_attribute(query, attr, ordinal=ordinal, tensors=values, is_array=False).wait()
return True
except OvstageError as err:
print(f"ovstage write failed (code {int(err.code)}): {err.message}")
return False
The synchronous status helper used by waitOp() is:
/// Check a synchronous status from stage, using what to identify the failed call.
/// Return on OVSTAGE_OK; otherwise print the status and available error text and exit the example.
static void check(ovstage_instance_t* stage, ovstage_api_status_t status, const char* what)
{
if (status == OVSTAGE_OK)
return;
std::fprintf(stderr, "ovstage %s failed (code %u): %s\n", what, status,
stage ? ovstage_get_error_string(stage, status) : "(no instance)");
std::exit(EXIT_FAILURE);
}
The wait helper checks both the returned status and failed operation IDs:
/// Check submission of enq to stage, wait for the operation and its dependencies, and report errors using what as the call label.
/// On success, release operation tracking before returning. This example prints failures and exits; applications can propagate errors instead.
static void waitOp(ovstage_instance_t* stage, ovstage_enqueue_result_t enq, const char* what)
{
check(stage, enq.status, what);
ovstage_op_wait_result_t wait{};
const ovstage_api_status_t code = ovstage_wait_op(stage, enq.op_index, OVSTAGE_TIMEOUT_INFINITE, &wait);
for (size_t i = 0; i < wait.error_op_id_count; ++i)
{
const ovx_string_t e = ovstage_get_last_op_error(stage, wait.error_op_ids[i]);
std::fprintf(stderr, "ovstage %s op %llu failed: %.*s\n", what,
(unsigned long long)wait.error_op_ids[i].raw_id, (int)e.length, e.ptr ? e.ptr : "");
}
if (wait.error_op_id_count != 0)
std::exit(EXIT_FAILURE);
ovstage_release_op(stage, enq.op_index);
check(stage, code, what);
}
Status Codes#
Use ovstage.ErrorCode names, not numeric values. C uses the corresponding
constants in ovstage_api_status_t: OVSTAGE_OK for ErrorCode.OK,
and OVSTAGE_ERROR_* for the other members.
Status |
Meaning |
|---|---|
|
The call succeeded. For an enqueue, this means it was accepted. |
|
An argument is invalid. |
|
The handle is invalid or has been released. Do not reuse a query, read, map, or group handle after releasing it. |
|
The requested item was not found. |
|
Despite its name, this reports an existing prim rejected by |
|
A mutation conflicts with an applicable watermark or retained value/prim-lifecycle change under the configured admission policy, or a read selects an unsealed change at or before its requested end. The end itself is not compared with the watermark. |
|
This build does not support the operation or requested data. |
|
The call cannot be admitted now. A |
|
There are no more results to fetch. |
|
An allocation or size calculation failed recoverably. |
|
The attribute layout changed during a map operation. |
|
The wait or fetch did not finish within its timeout. |
|
An asynchronous operation failed. Inspect its diagnostic. A wait reports an execution failure as |
|
The requested ordinal range cannot be read from the retained values, because a selected prim and attribute changed again after the range end. See Remediation. |
|
An internal error occurred. |
ovstage.Read.fetch_next() and ovstage.Map.fetch_next() return
None at the end of iteration rather than raising an exception.
Remediation#
Status |
What to do |
|---|---|
|
For a write, delete, or clone, use an ordinal above the watermark (write floor in the API) of every attribute it touches and satisfy the configured ordinal-admission policy (Ordinal Admission Policies). A write submitted after an advance can still be accepted at submission and fail when it runs, so check the wait result as well. For a read, advance the watermark to cover the changes you want, wait for the advance to complete, and read again. |
|
The range ends before a later change to a selected prim and attribute. Only the latest value is retained, so read through the later ordinal or read the latest state instead. |
|
A read group, map, or pending write covers the same attribute on the same prims, or a read group covers a prim that the write, map, delete, or clone would give |
|
The handle was already released, never existed, or belongs to another instance. Keep one owner per handle and release it once. |
|
Retry the refused call after the floor advance or the presenting step returns. Limit the number of operations you keep in flight. See Earlier Values of Selected Pairs. |
Copy an error message immediately, on the thread that made the call. Error state is per thread, and a later wait or internal wait on that thread can clear or replace it.
See ovstage Overview for diagrams explaining watermark and range-read errors. A watermark advance to a lower ordinal has no effect; it does not move the watermark backwards or report a watermark violation.
Recovering from a Failed Write#
A failed batch can leave some changes applied:
Successfully completed entries remain applied when a later entry fails. The API does not return a list of completed entries. Repair a batch that may have partly succeeded using a newer ordinal.
If no entry completed, a corrected retry at the same ordinal may be accepted, subject to the current watermark and other write rules. This includes a one-entry write whose change was not applied successfully.
A failed write can leave a prim or attribute visible to queries. Visibility alone does not prove a change was recorded.
PrimMode.INSERTcan reject this existing target;PrimMode.UPSERTcan repair it.
Check every write’s completion and finish any repair before advancing the watermark. A successful advance does not report earlier write failures or undo completed entries. If a repair uses a newer ordinal, advance the watermark through that ordinal only after the repair succeeds.
Completed metadata writes count as successful entries, even when they happened while preparing the rest of the batch. Allocating ordinary attribute storage alone does not count as a successful write.
Under STRICTLY_INCREASING, replaying completed cells at their recorded
ordinal is rejected. Disjoint unfinished cells may still admit a same-ordinal
retry; NONDECREASING and FLOOR_ONLY may also allow replay of completed
cells. Every retry must satisfy current watermarks, the selected policy, and
stage state. Failure does not reserve an ordinal for later retry. See
Ordinal Admission Policies.
Note
A successful repair can record attribute changes without recording creation
of a prim left present by the earlier failure. Do not infer creation events
from query visibility. The ovstage.Stage.write_attributes() reference
describes the full recovery contract.
In C, a synchronous recoverable allocation failure returns
OVSTAGE_ERROR_OUT_OF_MEMORY. A failure during an enqueued write is reported
as OVSTAGE_ERROR_OP_FAILED through the wait, with the allocation error in
the operation diagnostic.
Warning
Recoverable allocation failures use the error reporting described above. If an update has already changed data and the runtime cannot keep the stage consistent, it terminates the process instead. This failure cannot be handled as a returned status or Python exception.
Diagnostic Messages#
Python exceptions carry the error message. In C, use the accessor that matches the failure:
Accessor |
Result and lifetime |
|---|---|
Static, non-null |
|
Borrowed |
|
Borrowed |
An unknown or non-failed ID returns an empty view from
ovstage_get_last_op_error(). See String Handling for copying returned
strings and Asynchronous Operations for timeouts.
Map Commit Failures#
A rejected ovstage_unmap_group enqueue leaves the map and group unchanged.
Except for availability-event record failures,
after acceptance, execution failure makes the map terminal; final unmap reports
that failure while releasing it. Repair uses a new map or write, not another
commit attempt in the failed session. A failed write does not commit new prims
or attributes, schema or semantic changes, hierarchy connections, or value and
prim-lifecycle change records. It also records no new ordinal ownership. Groups
committed earlier remain committed, including their structural changes.
Successful final unmap commits only remaining groups and does not repeat changes
from earlier commits.
Map commits are not transactional and provide no rollback guarantee. A failed write may have modified some stored rows; these partial changes can be observable even though the write was not recorded as successful. Do not infer which rows completed from those changes or treat final unmap as an atomic commit of the whole session.
An unplaced map uses CPU storage, so any such unmap that still has payload to
commit rejects a non-zero cuda_stream or cuda_event. That rejection is
an accepted failure and is therefore terminal for the session: finalize with
ovstage_unmap_attribute and start a new map to retry. A cleanup-only close
of ovstage_unmap_attribute – every group already committed by
ovstage_unmap_group – has no payload and never inspects the sync, so this
is not a general argument check.
Placement Availability Failures#
The experimental placement extension has a post-commit exception: if CUDA
refuses to record availability_event, an otherwise successful write or map
commit reports OP_FAILED while its values, change records, and ordinal
ownership remain committed. Retrying must satisfy the configured admission
policy; STRICTLY_INCREASING requires a newer ordinal for those cells.
A failed event record on unmap_group leaves the session open, while final
unmap_attribute still consumes its handle. A placed read fails instead of
returning payload. An operation completed during enqueue can report this
failure synchronously after its effects have occurred.
The event remains untouched and cannot prove device completion. After observing
the failure, retain write sources until synchronizing the specific placement
stream, or the recording device for a default/per-thread stream. An ordinary
synchronous rejection owes no event record; do not blindly wait on the event
after rejection. See Completion, Availability, and Buffer Lifetime and the
ovstage.Placement reference for ordering, lifetime, and allocation-failure
details. Event completion alone never replaces checking operation status.
Query Refresh Failures#
In this implementation, a failed query refresh after a structural change marks all ready query handles on the stage as failed, including unrelated queries. Release and recreate those handles; retrying them does not restore readiness. The refresh failure is not reported on the operation that caused the change, which can still report success. It first surfaces when an affected handle is used, currently without a diagnostic message.
GPU Write Completion Failures#
In this implementation, if the stage cannot confirm that a CUDA write finished,
every later attribute read, attribute write, and structural change on that
stage reports OP_FAILED, including attributes that no CUDA write touched.
CUDA reports an asynchronous device fault on whichever later query observes
it, so the failure cannot be attributed to one write or attribute. Waiting or
retrying does not clear it. Destroy the stage and create a new one; whether
the process can continue to use the CUDA device depends on the fault.