SQL over the data in Restate
Restate exposes the following SQL tables:sys_invocation: to inspect invocationssys_journal: to inspect the invocations’ journalsys_journal_events: to inspect the events of an invocation, such as failuressys_inbox: to inspect the queue of invocations waiting for a Virtual Object or Workflow keysys_locks: to inspect the locks held on Virtual Object and Workflow keyssys_vqueues,sys_vqueue_meta,sys_vqueue_entry_status: to inspect the virtual queues in which invocations wait for their turn to runsys_scheduler: to inspect the scheduler state of virtual queuessys_rules,sys_user_limits: to inspect concurrency-limit rules and the limits in usesys_service: to inspect the registered servicessys_deployment: to inspect service deploymentssys_promise: to inspect durable promises of workflowsstate: to inspect application state
restate sql --help lists the tables and restate sql describe <table> shows the columns of a table.
The Restate Introspection SQL API has been implemented based on DataFusion and supports standard SQL syntax.
Inspecting invocations
You can execute SQL queries via the CLI or over HTTP.Listing ongoing invocations
Listing ongoing invocations
For each of the queries we will show the CLI command and the equivalent SQL query that you can execute via the CLI or over HTTP.Active invocations are invocations that haven’t completed yet.
Completed invocations are retained for the configured retention time, after which they are removed from the
sys_invocation table.The CLI command only shows the active invocations, not the completed ones. Use --all to see completed ones as well.Retrieving the status of an invocation
Retrieving the status of an invocation
scheduled: will start at a later time (a delayed call)pending: queued behind other invocations, for example on the same Virtual Object key or for a concurrency limitready: ready to be processed, but not yet runningrunning: actively processingbacking-off: retrying due to a failuresuspended: waiting on some external input (e.g. request-response call, awakeable, sleep, …)paused: stopped until resumed, because it ran out of retries or was pausedcompleted: completed, successfully or with a failure (shown until the retention time expires)
The
status column of the sys_invocation table shows an invocation that is retrying as ready.
The CLI combines it with the sys_vqueues table to show backing-off and the retry count, see Inspecting invocation retries.Inspecting the invocation journal
Inspecting the invocation journal
restate invocations describe shows a preview of the journal, with the first and last entries.
Use restate invocations journal to see all of it:Inspecting invocation retries
Inspecting invocation retries
To have a look at the invocations that are currently in a retry loop, you can execute:The
sys_invocation table shows a retrying invocation as ready, so the SQL query looks at the virtual queues instead.
Join with sys_invocation on the entry_id column to get the details of the retrying invocations, or use restate invocations describe to see the retry count and the last failure.Listing invocations that are blocking a Virtual Object
Listing invocations that are blocking a Virtual Object
You can retrieve the invocation ID that is currently blocking a Virtual Object via:The lock of a Virtual Object key has the name With the CLI, you can also drill down and list only invocations that are blocking any Virtual Object:Add
service/key.
Each scope has its own Virtual Object instance with its own lock, with the same lock_name but with the scope column set.
Filter on scope is null for the unscoped instance, or on scope = 'my-scope' for a scoped one:--key my-key to list only invocations that are blocking a specific Virtual Object.You can then use the invocation ID to cancel the invocation.Checking the last time an invocation was modified
Checking the last time an invocation was modified
running to suspended, or when the last journal entry was added.Checking how an invocation was triggered
Checking how an invocation was triggered
To find out if an invocation was triggered via the ingress or by another service:With the CLI, you see the caller in the invocation information. For an invocation triggered via the ingress:For an invocation triggered by another service, you see the calling handler and its invocation ID:For the SQL queries, the
invoked_by field contains ingress, service, or subscription for invocations created by a Kafka subscription.
If the invocation was triggered by another service, then the fields invoked_by_service_name and invoked_by_id will supply more information about the invoking service.
See the sys_invocation reference for all values.Retrieving the trace ID of an invocation
Retrieving the trace ID of an invocation
Listing inactive invocations
Listing inactive invocations
To list the oldest invocations that are not making progress:
Listing zombie invocations
Listing zombie invocations
Zombie invocations are invocations that are pinned to a specific deployment but that deployment was forcefully removed. You can list them by executing:For the SQL queries, you need to know the deployment ID of the deployment that was forcefully removed.
Inspecting application state
With the CLI
To retrieve the state of a specific service and service key, do:--binary flag,
and get the value as base64 encoded string.
Use --plain to retrieve the state as a JSON object.
This can be useful in combination with tools like jq for example:
--scope <SCOPE> to retrieve the state of a scoped instance.
With SQL queries
You can query the application state via thestate table.
value_utf8.
The scope column is NULL for the unscoped Virtual Object instance, and contains the scope for scoped instances.
To retrieve the state of a specific service name, service key and state key, do:
ctx.set("count", 1) stores 1 under the key count.
Joining the sys_invocation and state table
Joining the sys_invocation and state table
To join the
sys_invocation and state table:Edit application state
You can edit the application state either via the state tab of the UI or via the CLI:RESTATE_EDITOR, VISUAL or EDITOR (in that order), falling back to vi.
It sends the new state values back to the runtime to be applied.
Use --binary if the values are not JSON-encoded UTF-8 strings.
In this case, you need to decode the base64-encoded string, and encode it back to base64 after editing.
Add --scope <SCOPE> to edit the state of a scoped Virtual Object instance.
An example on how to edit the K/V state of the service counter for the key bob:
restate state edit needs a terminal. Scripts and coding agents change the state with restate state patch instead, which applies a JSON Patch to the state and supports --dry-run and --yes:
restate state clear: