Skip to content
sinc-LLMBook a 15-minute call

How to Give Parallel AI Evaluators the Same PostgreSQL Snapshot

Export one PostgreSQL snapshot, import it in each evaluator, and test that later commits stay outside the comparison.

On this page

By Mario Alexandre · November 29, 2026 · 24 min read

Export one PostgreSQL snapshot when parallel AI evaluators must read the same committed rows while the application keeps writing. Start each evaluator in a fresh read-only Repeatable Read transaction and import the snapshot before its first query. Keep the exporter open until every import succeeds, then retain an immutable input manifest for scoring and later reruns. If the comparison spans other systems, freeze those inputs at their own boundaries as well. PostgreSQL documents the lifetime and import rules for a shared snapshot. PostgreSQL snapshot synchronization SET TRANSACTION

TL;DR. Give both arms a single snapshot and prove it with a late write. The imported sessions must agree on the original row revisions, and a fresh control session must see the new revisions. If an evaluator misses the import or reads on another connection, hold the comparison rather than quietly replacing its data with newer rows.

Key decision facts

Requirement Starting method End-to-end evidence
Parallel readers need one database view Export once, import in each fresh transaction before its first query Both ordered input manifests match
A later write must stay outside the test panel Commit a late insert and update from a separate writer The fresh control sees them and both imported readers do not
Evaluators need time for long model calls Extract supported inputs, verify manifests, and close transactions Model workers consume the exact frozen artifact without a new data query
A later rerun must recover the panel Store permitted bytes or immutable revisions plus digests A separate operator reconstructs input identities and verifies the same values
A tool or vector index contributes data Freeze and check that source separately The returned item revisions or bytes are bound to the same evaluation case

Decide which data must be shared

Begin with the intended comparison. Suppose a review team wants to compare two prompts for extracting purchase details from documents. The team wants both prompts to receive the same review cases and labels. If one arm sees a corrected label and the other sees the original, a score difference could come from the label revision or the prompt. For this experiment a shared view of the dataset is a precondition. If the team instead wants to evaluate two full systems on the inputs each would retrieve independently, freezing their internal data can hide part of the difference it intends to measure.

Write down which input is fixed and which variable is changing. Limit the comparison to one surface that answers a release question, such as extraction recall on cases admitted to a named panel. The query that builds the panel then has an explicit output contract. It should identify case IDs, exact input revisions, label revisions if they are in scope, and the ordering used for a manifest. The experiment contract must also say whether any eligible cases can be omitted when a row is incomplete. Otherwise two arms could share a snapshot and apply different eligibility rules after reading it.

Compare data at the level the product uses. A case ID can stay constant while the text, answer key, attached file, or workflow stage changes. If the objective is input equivalence, save revision identifiers or digests for the fields the model actually received. A matching list of case IDs does not by itself identify the inputs. A different document revision may retain the same file URL, and a cache can serve an old response under that URL. A controlled extract with explicit revision identity gives the operator a specific fact to test.

Use an exported snapshot when multiple sessions need to perform independent reads from one database at a shared visibility point. If reading once in a single transaction and distributing the resulting immutable artifact meets the requirement, that can be simpler. Choose multiple imported transactions when partitioned extraction, independent readers, or comparing two data-access code paths provides a useful capability. The additional connections and coordination should serve the comparison. One shared view does not require the inference jobs themselves to hold database connections.

Distinguish a frozen database input from a frozen evaluation configuration. Record the rubric, model, prompt, tool behavior, and the intended alternative under test. Use a pinned time parameter if eligibility depends on a date. A repeatable-read snapshot governs which versions of rows are visible. It does not ensure that calls to a clock, randomness, a remote service, or a model deployment return identical values. An evaluator that computes a rolling cutoff inside its own transaction can select a slightly different panel even when the database view is shared.

Establish the snapshot before either evaluator reads

Open an exporter connection to the intended database and begin a read-only transaction at Repeatable Read. Run pg_export_snapshot() in that transaction and keep it open. The identifier names the snapshot the exporting transaction is using. PostgreSQL permits another transaction to import it while the exporter remains open. Use a fresh evaluator transaction for each import and set its isolation level before applying the snapshot. The import needs to happen before the first query or data modification. PostgreSQL snapshot functions

Start with the following illustrative commands. Use the actual identifier from the exporter in each evaluator. Set the environment's normal limits and use connections intended for the test. The sample selects two columns to show row identity. A real evaluation needs a manifest that includes every input aspect required by its acceptance criteria.

-- Exporter connection. Keep this transaction open until all imports succeed.
BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY;
SELECT pg_export_snapshot();

-- Run in each evaluator connection using the actual returned identifier.
BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY;
SET TRANSACTION SNAPSHOT 'replace-with-exported-snapshot-id';
SELECT case_id, input_revision
FROM eval_cases
WHERE panel_id = 'fall-check'
ORDER BY case_id;

Check the driver's handling of the command. PostgreSQL requires the identifier in the import statement as a string literal. Follow the actual driver's supported composition for the server-issued identifier and preserve the established connection's transaction boundary. Keep pool calls, ORM discovery queries, and retries in view. A driver can open a transaction implicitly or issue a query before the intended import. A convenient diagnostic query on the importing connection can itself invalidate the order. Collect connection identity from driver evidence or use in-transaction readback after the import when appropriate.

Keep the same connection for all queries that rely on that snapshot. Starting a transaction on one acquired connection and invoking a repository function that borrows another can mix data without an obvious error in the orchestration layer. Use the application's genuine data-access path in the test. An explicitly imported connection that your ORM never queries provides no evidence for the input the evaluator sent to the model.

The PostgreSQL documentation allows an import at Repeatable Read or Serializable. The sample uses Repeatable Read. A Serializable importing transaction requires a Serializable exporter, and PostgreSQL specifies further restrictions for a non-read-only Serializable importer. Do not assume the same session settings work across isolation levels. Test the actual connection defaults and capture settings after an import. Read Committed takes a new snapshot per command, so it is unsuitable for this import. PostgreSQL SET TRANSACTION and import restrictions

Treat each import as a handoff with a deadline

Before exporting, list the evaluators expected to attach and how the exporter will learn that each import succeeded. A successful dispatch to a process, receipt of an identifier, and a successful import are three different observations. Require a signal tied to the specific evaluator role, the intended transaction, and its successful import. If a launch retries under a new connection, it must report the new import rather than copying an acknowledgment issued by a lost connection.

Give the handoff a bounded coordination window. If an evaluator does not import in time, choose whether to wait within the stated limit, extract a shared artifact from a surviving valid session, or cancel the comparison. The choice depends on what the experiment measures. If the two arms are comparing data access code, replacing a missing reader with input from its peer can invalidate the test. If the purpose is comparing prompts and there is one honestly frozen input artifact, both arms could consume it under a revised evaluation plan. In either case the decision and evidence must identify the exact input generation.

After every intended evaluator confirms import and pinned read behavior, the exporter no longer needs to remain open for those imported transactions to use their transaction snapshots. It does need to remain open for any future imports. Close and release all read transactions promptly after extraction. A later retry should normally use the immutable extract. PostgreSQL's visibility model can retain older row versions for open transactions. Long transactions held for inference can tie database maintenance to unrelated model latency. PostgreSQL snapshot synchronization PostgreSQL routine vacuuming

An illustrative coordination ledger might have one row per evaluator with a role, run reference, session identifier, import status, and extract result. Use the logs to establish the first observation expected from each stage. If a process exits after acknowledging import but before its query completes, the evaluator's data remain missing. If it saves valid output and exits before acknowledgment, read the artifact and its binding with the same standard you would use for a normal handoff. Completion depends on available evidence, not which process reported success first.

Prove the difference with a late commit

Build a disposable database fixture with case C101 at revision three and case C102 at revision four in the evaluation panel. Establish the exported snapshot and leave the exporter open. From a different connection, update C102 to revision five and insert C103 at revision one, then commit. This publication order is essential. It gives the fixture a positive control that the independently committed changes are visible to readers using a newer view.

Start each evaluator in its own fresh transaction after that write commits. Import the shared snapshot, then run the same read contract from both. Use a separately opened fresh control session on the same authoritative database to run the query without importing. Start it after the write commits. Observe exact rows and versions, not merely counts. Then end the exporter, open an additional disposable evaluator transaction, and attempt a late import. The late importer should fail because the original exporter has closed. PostgreSQL snapshot synchronization functions

Fixture path Expected results If the expected result is absent
Evaluator A, successful import C101 revision three and C102 revision four Check its transaction, read path, and actual import selection
Evaluator B, successful import The same IDs and revisions as A Check pool routing and whether an application query opened another transaction
Fresh control after the writer commits C101 revision three, C102 revision five, and C103 revision one Confirm the writer commit, read target, filter, and control transaction start
Disposable evaluator after exporter closes The attempted import fails Confirm it tried the original identifier after the original exporter closed
Deliberately broken evaluator that uses a fresh connection It exposes the later view and the input gate rejects it Check that the harness compares revisions and data actually sent to the model

Require both a passing result and a useful negative control. If every connection reports the original data, the import may be working or the late change may never have reached the chosen read target. If both actual evaluator connections report the newer data, a comparison of the two extracts can still succeed even though the snapshot mechanism was bypassed. The fresh control and the original fixture expectation distinguish those cases. Keep the expected old values in the fixture contract before collecting the actual results.

Make the broken evaluator realistic enough to distinguish the failure mode that matters. In the test harness, give it a fresh connection after the late commit while preserving the query and other settings. If the acceptance check reports a shared snapshot, the oracle is comparing the wrong facts or failing to observe the input path. A separate control can replace one payload while keeping case IDs constant. The gate should catch the change through the revision or digest. These deliberate defects protect against a deceptively reassuring equality check on the cohort size.

Add one trial with no late insert. Let the writer update C102 while the case count remains two in both views. This is a useful test for evaluators that check only panel size or case IDs. A system can produce a defensible comparison with equal case counts only if it also proves that the versions and permitted input values matched. The payload checks become especially important when source systems can overwrite data in place or reuse a revision label.

Build a manifest that another operator can reconstruct

Separate information about the query from information about its observed output. Record which database the extract read, which data definition or query revision it used, the frozen query parameters, and the read scope granted to its role. Record the panel ID, extraction run identity, and the source revisions of rows returned. If the query takes a cutoff, store the exact value and its timezone convention. A saved identifier for the query with no parameters can produce an apparently successful rerun with a different panel.

Give every case a predictable position or a stable key supporting deterministic comparison. In the example, ordering by a unique case ID makes the manifest straightforward. If an extract joins several relevant rows for one case, define a complete stable ordering or compare the declared set by keys. If two distinct rows share the supposed unique key, the comparison must stop until the key is clarified. A sorted list of digests can obscure a difference when two payloads swap positions. Bind each digest to the case ID and its role, such as input, label, or supplemental context.

Calculate digests over a specified representation. Two evaluators can read the same database values and emit different JSON whitespace, time formatting, or numeric strings. Decide whether the comparison should bind exact bytes or normalized values. An effective procedure captures the exact bytes sent to the model when byte equivalence matters and stores a deterministic encoding of logical fields for ordinary manifest comparison. A normalization that drops a material field can mask drift. Test by modifying the field the model actually consumes and checking that the acceptance rule notices.

Retain authorized input bytes or references to immutable content that remains available under the appropriate permissions and retention policy. The snapshot token describes a live database visibility mechanism. It cannot be imported in a new connection after its exporter ends. A digest can verify material you still have; it cannot recover the bytes by itself. For sensitive cases, keep only the allowed material, and record whether a later operator can reproduce the full inputs or only verify a narrower claim about IDs and revisions.

Consider what the consumer actually reads at replay. A service may load the frozen document text from storage while looking up an answer label from the currently active evaluation table. That split recovers only part of the comparison. Bind each input separately and run a cold replay without borrowing the original worker's in-memory values. If some inputs must be regenerated, label that rerun as a new evidence episode using the recorded revisions available now. Do not claim exact reproduction where a source can expose only its current version.

An example manifest for one panel can identify the selection query, the ordered rows consumed, and the conditional behaviors if an input is unavailable. Keep descriptive, non-sensitive references in ordinary reports. Source content and reusable artifact locations should follow the access policy for the underlying cases. Make the relationship between the extracted bytes and their digest visible to a reviewer with ordinary allowed access. This leaves the operator a reproducible identity check without broadening who can read the underlying evaluation data.

Recover an interrupted partition without mixing panel generations

Consider a synthetic extraction divided into four ranges of twenty-five case IDs. Each SQL worker imports the same PostgreSQL snapshot. Three finish with twenty-five cases each and commit their output to the intended immutable dataset generation. The fourth worker loses its connection before making a durable extract. The coordinator sees seventy-five accepted cases from three admitted ranges. Its responsibilities include deciding what proof the fourth range needs and keeping the seventy-five verified cases visible until that decision settles.

If the exporter remains open within the authorized coordination window, open a fresh evaluator transaction and import the original snapshot. Check that it reads exactly the missing range and writes an output bound to that same input generation. When the new twenty-five are accepted, reconcile four unique range identities and one hundred distinct case IDs. A result claiming one hundred rows is insufficient if two ranges overlap. Build an index keyed by case ID, and compare the observed set to the contract for each range.

If the exporter has already closed and there is no durable copy of the missing inputs, deliberately try the rejected path in the fixture. Start a new evaluator on a later snapshot for the last range. Include an update to one case in that range after the original snapshot. A mixed extract may still contain exactly one hundred unique cases. The combined result must be rejected because it no longer describes the intended shared view. A verifier that accepts a matching total cannot establish common provenance. The correct recovery under the shared-view contract is to use a verified immutable copy of the missing original range or establish a new generation for the whole panel.

If the worker reached object storage before it disconnected, the coordinator needs the durable artifact, not just the worker's logged completion. Check the generation, exact range, expected digest if one was recorded before interruption, access boundary, and committed state of the upload. A partially written file may be syntactically valid while truncated. Compare the declared range coverage and bind the exact bytes to the new aggregate manifest. The evidence that resolves the incident is a successful inspection at the storage destination, plus an observation supporting the artifact's relationship to the original snapshot.

Test a case where a replacement worker writes its range while the old worker actually completed before it disconnected. If the original and replacement writes contain the same expected bytes, the collection mechanism may permit selecting one canonical object and recording the duplicate attempt. If two bodies disagree under the same generation and range, halt the join and inspect their provenance. An implementation that silently chooses the newer file can introduce the inconsistent snapshot work the test was designed to detect. Have the publisher refuse inconsistent replacement until the input generation has been reconciled.

Under a workload where the panel is regenerated, name the downstream obligations that must restart. Model calls already issued for an earlier generation may return useful responses for that earlier panel, but they are ineligible for paired scoring with cases from the new view. Keep model results and input generations linked even if the case IDs recur. This also gives finance and operations a correct count of attempted calls when one interrupted extraction causes repeated work.

Use the trial to decide how much coordination time is worth purchasing. Long enough for a replacement import can avoid rebuilding the panel. Long-lived database transactions also have maintenance costs. Compare the measured time to publish an immutable extract with the allowed time the database can support the live snapshot, using the same workload. When an immutable dataset fits the task, committing it before launching the evaluators can turn the interrupted connection into an artifact read retry instead of a new database visibility problem.

Record one recovery boundary in the run policy. For example, after the extraction deadline the coordinator cancels missing or unfinished transactions, keeps already accepted ranges for diagnosis, and requires either complete generation evidence or a full rerun for paired scoring. If the project legitimately permits a partial panel, define the acceptable coverage and changed inference explicitly. An evaluation intended to cover a representative sample of twelve case classes cannot assume that completing three arbitrary ranges preserves every class's coverage. Inspect the observed omissions and count them in the result.

If an object appears after the worker loses its acknowledgment, compare its immutable version and range digest with the same-generation manifest before accepting it. If provenance is missing, reject that range for paired scoring. Open a new generation for all ranges and tie subsequent model results to it. One hundred distinct IDs can show completeness while still hiding a changed record version.

Diagnose a mismatch before scoring either arm

Start with a comparison of manifest keys and values at the same boundary. If one arm has a case the other omitted, identify the first divergence in its path. The divergence may be a filter, missing source, different snapshot, authorization scope, or transform. Compare upstream selected IDs, effective query parameters, actual connections, imported state, and the downstream serialized requests. A difference observed only at the final score cannot identify which cause is responsible.

Use the late-commit fixture to inspect different histories. If the intentionally fresh control sees the new row and the first evaluator does too, that evaluator may have skipped the import or performed the actual query on another session. If the initial extraction agrees but the prompt inputs differ, look at the code or tool that constructs the actual input. The imported snapshot can be correct while resource selection later uses a live view. Capture the revision or digest at the input assembly boundary and compare it to the frozen manifest.

If the importer fails, classify the actual failure first. An attempt after the exporter ends needs a valid durable artifact or a new evaluation input generation. An import in an already-used transaction needs a clean transaction with the correct ordering. An ORM that reconnects during a read should surface a lost extraction attempt. A successful retry with a newly selected snapshot changes the evidence lineage, even if it produces an identical case count. Record such a run separately so paired results cannot accidentally be combined across generations.

If the fresh control misses the late write, inspect its authority and timing. It can be on a read target that has not yet observed the commit, it can filter out the late record, or it can have adopted its own transaction view earlier. Confirm the committed write and run the control after that evidence on the intended server with the same row predicate. Only then can the old-view behavior distinguish a successful import from an undiscriminating setup. Do not use the comparator's agreement as a substitute for a functioning positive control.

If counts, revisions, and digests agree but response behavior differs unexpectedly, keep the input evidence and investigate the experiment itself. Check prompt configuration, tools, grading criteria, and any asynchronous path that might have substituted a response. A shared snapshot removes one plausible source of disagreement. It gives no guarantee that a model is deterministic, or that both arms are actually using the deployment they report. Keep each variable and its observing source distinct.

Observation What it establishes First follow-up
Same case count Both extracts contain the same number of entries Compare case IDs and exact input revisions
Same IDs and different values Scoring inputs may differ within the matched cohort Follow changed revisions or canonical bytes to the effective read
Manifest and prompt input disagree The data changed or transformed between extraction and consumption Inspect the actual request assembly and tool evidence
Both imported readers show the late write The test failed to prove the older snapshot reached their reads Verify actual imports and connection identities
The fresh control fails to see the late write The control cannot distinguish the views Check commit, target, timing, and predicate
A missing arm has no durable artifact There is no supported pair for its affected cases Apply an established recovery policy or hold the result

Decide when to use a shared extract instead

An evaluation can choose a single read-only transaction and materialize input once. Both arms can consume its exact output without separate imports. Use this when the experiment tests the treatment of the same payload and the input fits a bounded extraction. It avoids coordinating many transactions and makes reruns simpler when the artifact can be retained. Test that each arm actually reads that saved generation. A configuration option describing a frozen dataset is weak evidence if either arm silently calls the live database when an input is missing.

Multiple imported transactions help when readers must exercise their own queries over the same state or when extraction needs a carefully defined partition. If you partition on stable keys, save which reader owned each partition and the expected combined coverage. Two correct snapshots can still produce duplicate or missing cases when assignment logic overlaps or skips ranges. Keep an independent inventory of expected partitions and check the identities at the join. A worker's successful completion statement provides no evidence for keys it was never asked to read.

If you only need yesterday's immutable published dataset, a versioned artifact or an application-managed revision can provide the appropriate input directly. Verify that the revision is immutable and complete for the intended fields. If data are scattered across multiple services, aim for an explicit collection cutoff and record versions at each service. A PostgreSQL snapshot does not freeze a vector index or object store. If it reads metadata that points to objects outside the database, pin those object versions or store authorized retrieved bytes under the corresponding case identities.

Test the external dependency with a deliberately changed object. For instance, change a test document in the object store after the database snapshot while retaining the same locator. A live fetch by locator could see a different object despite matching database rows. Your acceptance gate should reject a changed digest or obtain the originally pinned object version. A gap can also occur in a retrieval-based evaluation if the recorded query targets an index whose contents have changed. The evidence should identify the index or the returned passages that are intended to remain fixed.

Walk a paired comparison from extraction to a release decision

Consider a synthetic panel with twelve eligible records. Both evaluators import the same snapshot and produce matching manifests of twelve case IDs, input revisions, and labels. Model A responds to all twelve cases. Model B responds to eleven and times out on one. An evaluation based only on common successful responses can now report an apparent change on eleven cases while hiding the missed outcome. Record the twelve intended pairs, the eleven completed pairs, and the status of the missing response before calculating the outcome metric.

Suppose the eleven complete pairs contain seven cases where both models meet the rubric, two where only A meets it, one where only B meets it, and one where neither meets it. The observed rubric success among complete pairs is nine of eleven for A and eight of eleven for B. If the goal is operational success on all intended cases and a timeout is unsuccessful under the frozen rubric, count each arm using all twelve. To finish that calculation you also need A's rubric outcome on the unpaired case. If A met the rubric there, its operational success is ten of twelve and B's is eight of twelve. If A failed, the figures become nine of twelve and eight of twelve.

Decide the handling of the missing result before testing. If the timeout is a separate outcome rather than a failed rubric on a response, report availability and response quality on their respective populations and keep the unpaired case visible. Record follow-up policy for a retried response on the original input bytes. A retry under a different time budget or tool configuration can tell you something about recovery, but it belongs to a separate policy comparison. Use the established scoring definition consistently across the two arms. sinc-LLM on pairing the same shadow requests

This fixture has three independently checkable counts. The eligibility query defines twelve intended cases. The exact manifests show twelve matched input sets. The terminal outcome join shows eleven completed pairs and one incomplete pair. A passing extraction and a missing model response can coexist. Holding the stronger conclusion when a pairing prerequisite fails is part of the experiment design, even when the extracted data have already passed their checks.

Use an evidence worksheet for promotion

Before scoring Save this observation Hold when
Define selection Query revision, explicit cutoff, expected fields, and panel owner Selection can change silently between arms
Establish shared view Export origin, successful import acknowledgments, and late-commit control A required evaluator cannot prove the intended input path
Freeze consumed bytes Matching keyed manifests and allowed retained input references Values or revision identities differ or are unavailable
Join responses to planned pairs Each intended case and the terminal disposition of both arms Reports hide missing outcomes or replace rejected pairs
Reconstruct on transfer A second operator recreates the input identity from retained material An essential dependency serves only newer data

Before the release review, ask a second operator to reconstruct one case from the manifest and confirm what both model workers received. Include a case that changed after the snapshot so a test using the live source would fail. The operator should be able to tell which field belongs to the selection query, which value came from the database view, and which content came from a separately pinned source. If those boundaries are hidden, improve the manifest or lower the claim to what is actually recoverable.

Release the comparison when the recorded pairs agree at the declared input boundary and the scoring rules handle each intended case. Hold when an evaluator's import, source revision, or actual consumed input remains uncertain. The decision record should distinguish a failed comparison setup from a model that performed poorly in a valid comparison. That distinction protects the next rollout from trying to tune a model in response to a defect in the evaluation harness.

FAQ

Do two Repeatable Read transactions automatically agree?

They can acquire their views at different visibility points. Two transactions started around a concurrent commit may see different rows under Repeatable Read. Synchronize them explicitly when the test depends on a shared state. Validate the difference with a control that observes a late commit. PostgreSQL transaction isolation

Can a second evaluator import the snapshot after the exporter closes?

No. A new import needs the exporting transaction to remain open. An evaluator that already imported can use its transaction snapshot for the rest of its transaction. Close the exporter after confirming all expected imports, and prefer an immutable input extract for reruns. PostgreSQL snapshot synchronization

Can I read a test row and import the snapshot afterward?

Set the isolation level and import before the evaluator's first query or data-modification statement. Check for an ORM or pool that already issued a query. Run a new evaluator transaction when that ordering has already been lost. PostgreSQL SET TRANSACTION

Does the snapshot freeze the current time used in filters?

Use explicit agreed time parameters for the filter. A snapshot governs visibility for database rows. Different transactions or external calls can still compute different values for a time-based condition. Record the cutoff, timezone convention, and query rules in the manifest so a replay uses the intended selection.

What should I keep if retaining full model inputs is prohibited?

Keep only records allowed by the data policy. Where permitted, retain the case IDs, source revisions, and a digest of the relevant representation, plus an explanation of the parts a later operator cannot recover. A future check may support the identity of inputs provided by an authorized source. It may be impossible to replay the exact model requests unless the original bytes or immutable revisions remain accessible.

What if the same PostgreSQL rows point to changing tool data?

Pin or capture authorized tool inputs separately using their actual source versions. Confirm what the model received and compare it with the case manifest. An unversioned external read can drift even if PostgreSQL returns the same locator. Test this by changing one disposable object after the shared database view is established and checking that the evaluator detects or avoids the change.

Sources