Distributed systems engineer: Transactions and Isolation
Original interview cases on invariant boundaries, concurrent histories, commit decisions, cross-shard recovery, compensation, projections, constraints, and retry semantics.
These prompts are original practice. They are not questions from a named employer or a live hiring loop.
1.A workflow moves one analysis job from queue A to queue B. The contract requires it to exist in exactly one queue after every committed move. What should the transaction protect jointly?
Show answer and explanation
- A guarantee two independently committed updates are atomic together
- Removal from A and insertion into B
- Only the worker's local counter
- Only the insertion log message
Answer: Removal from A and insertion into B
The invariant spans both state changes. A complete atomic move prevents a committed state with the job in neither queue or both, subject to the actual storage and failure contract.
2.A transaction writes two related rows but the storage API commits each row separately. A crash occurs after the first. What guarantee is missing for the pair?
Show answer and explanation
- Only a shared request timestamp
- Atomic commitment of both changes
- A guarantee using one function makes separate commits indivisible
- Only a faster second write
Answer: Atomic commitment of both changes
Application call structure does not establish transaction atomicity. The commit mechanism must cover the actual invariant and its failure boundary.
3.A transaction reads a value written by another transaction that later aborts. What phenomenon occurred?
Show answer and explanation
- A dirty read
- A guaranteed serial execution
- Only an index lookup
- A committed snapshot read
Answer: A dirty read
The read depended on uncommitted state that did not become a committed result. Whether it is allowed depends on the actual isolation contract.
4.T1 reads status 'queued.' T2 commits status 'running.' T1 later rereads the same row and sees 'running.' What phenomenon does this history illustrate?
Show answer and explanation
- A dirty read necessarily
- A duplicate insert
- A nonrepeatable read
- A proof both reads used one fixed snapshot
Answer: A nonrepeatable read
The same transaction observes a committed change on rereading a row. The observation is distinct from seeing uncommitted data.
5.A transaction reruns 'all jobs with priority≥8' and sees a newly committed qualifying row. What condition should a predicate-stability guarantee address?
Show answer and explanation
- Only changes to one previously returned row
- A changed qualifying row set
- A guarantee every row-set change is an uncommitted read
- Only a different sort order of identical rows
Answer: A changed qualifying row set
The query's membership changed due to another transaction. A guarantee about predicates must cover relevant inserts and updates, not only locks on rows initially returned.
6.A range query returns no matching rows. A lock strategy locks only returned rows and assumes the predicate cannot change. What gap can remain?
Show answer and explanation
- Only a changed value in a locked returned row
- A concurrent insert into the empty qualifying range
- Only the query string's capitalization
- A guarantee an empty result proves no future match can appear
Answer: A concurrent insert into the empty qualifying range
An empty result supplies no existing row to lock. Protect the predicate with a suitable mechanism or use a transaction design whose isolation and retry rules enforce the intended invariant.
7.Two workers read remaining capacity 10. Each independently computes and writes the absolute value 6 after allocating four units. Both allocations take effect elsewhere. What can the final stored 6 conceal?
Show answer and explanation
- One allocation's capacity decrement was lost.
- The capacity necessarily became 2.
- Only one worker ever read the value.
- A guarantee identical assigned values represent both changes
Answer: One allocation's capacity decrement was lost.
Both absolute writes can overwrite the same old-state computation. Coordinate the complete allocation invariant using appropriate conditional or transactional updates.
8.An atomic command decrements capacity by four only if the current value is at least four. Starting at six, two such commands execute with that atomic condition. How many can succeed?
Show answer and explanation
- 1
- 0
- Any number without changing capacity
- 2
Answer: 1
The first success leaves two, so the second cannot satisfy current capacity≥4. This conclusion relies on the supplied atomic check-and-decrement semantics.
9.A client reads version 9 and attempts 'replace only if version is still 9.' Another client has committed version 10. What must an atomic version check do?
Show answer and explanation
- Overwrite version 10 because the request arrived later.
- A guarantee a prior read reserves the version.
- Reject the stale replacement.
- Reset the version to 9.
Answer: Reject the stale replacement.
Compare-and-swap binds the effect to the expected current version. A stale read is not itself authority to overwrite a later committed state.
10.A value changes from A to B and back to A. A compare-and-swap checks only the value A, while the application needs to detect intervening changes. What metadata can help?
Show answer and explanation
- A suitable monotonically changing generation
- Only the current value again
- A guarantee equal current values imply no intervening history
- Only the object's display name
Answer: A suitable monotonically changing generation
The ABA pattern can hide history from a value-only comparison. A generation or equivalent lifecycle mechanism must have appropriate wrap, persistence, and identity rules.
11.An invariant requires at least one of two independent service channels to remain enabled. Two snapshot transactions each see both enabled and disable different channels. What risk exists without adequate conflict control?
Show answer and explanation
- Only a duplicate request ID
- Write skew that breaks the cross-row invariant
- Only a dirty read
- A guarantee separate write sets make every invariant safe
Answer: Write skew that breaks the cross-row invariant
Each transaction can make a locally sensible decision from the same snapshot while their combined writes violate the invariant. Protect the shared condition through an appropriate serializable or explicit coordination design.
12.A transaction is serializable but not required to respect real-time precedence across clients. What stronger relation is additionally needed for strict serializability?
Show answer and explanation
- Only sorting transaction IDs
- A serial order respecting completed-before-started transactions
- Only a larger snapshot timestamp
- A guarantee every serial order already matches wall time
Answer: A serial order respecting completed-before-started transactions
Serializability provides equivalence to some serial order. Strict serializability also preserves relevant real-time ordering of nonoverlapping transactions.
13.A transaction commits before another begins. A strict-serializable history places the second before the first. What is violated?
Show answer and explanation
- Real-time precedence
- A guarantee strict serial order ignores completion times
- Only uniqueness of transaction IDs
- Only the database's page order
Answer: Real-time precedence
Strict serializability constrains the serial explanation by completed-before-started order. Concurrent overlapping transactions may still admit multiple valid orders.
14.A history has dependency edges T1→T2, T2→T3, and T3→T1 under a valid serialization-graph model. What does the cycle indicate?
Show answer and explanation
- No topological serial order satisfies all those dependencies.
- The order T1,T2,T3 necessarily satisfies every edge.
- A guarantee cycles imply every transaction read uncommitted data
- Only the graph's drawing style is wrong.
Answer: No topological serial order satisfies all those dependencies.
A directed cycle prevents a linear order respecting all edges. Interpret the result using the model's actual edge definitions and assumptions.
15.A dependency graph has edges T1→T2 and T1→T3, with none between T2 and T3. Which order is consistent with those edges?
Show answer and explanation
- T3,T2,T1
- T1,T3,T2
- T2,T3,T1
- T2,T1,T3
Answer: T1,T3,T2
T1 must precede both others. T2 and T3 can appear in either order because the supplied graph imposes no relation between them.
16.Two transactions write disjoint keys but both read a shared predicate governing total capacity. Why is disjoint write-set checking insufficient by itself?
Show answer and explanation
- Read dependencies can connect the invariant.
- Only key spelling determines conflicts.
- A guarantee no shared write means all histories serialize.
- Only the number of transactions matters.
Answer: Read dependencies can connect the invariant.
Cross-record constraints can depend on reads and predicates. A correct isolation or locking argument must capture relevant dependencies beyond direct write/write overlap.
17.A database detects a serialization conflict and aborts a transaction. The application retries only its final write using values from the aborted snapshot. What should retry encompass?
Show answer and explanation
- Only changing the request's timestamp
- The transaction's decision-making reads and writes as required
- Only the rejected statement with stale decisions
- A guarantee an aborted snapshot stays valid forever
Answer: The transaction's decision-making reads and writes as required
An isolation retry may need a fresh transaction and recomputation of decisions. Preserve logical-request identity and external-effect safety while following the database's actual retry contract.
18.A retried transaction sends a notification before its commit, then aborts and retries. What side-effect issue should be addressed?
Show answer and explanation
- An externally visible effect from an aborted attempt
- Only the number of database rows
- Only transaction-ID formatting
- A guarantee database rollback retracts external notifications
Answer: An externally visible effect from an aborted attempt
Database atomicity does not automatically extend to external actions. Coordinate durable intent and effect execution with suitable idempotency or other defined semantics.
19.A transaction increments a business counter and writes its processed-request marker in the same atomic commit. What failure gap does this specifically help close?
Show answer and explanation
- Only duplicated network packets before any processing
- Every form of stale read
- Repeating the effect after a crash between separately committed effect and marker
- Every possible external side effect
Answer: Repeating the effect after a crash between separately committed effect and marker
Coupling the effect and marker prevents a committed effect from lacking its deduplication record under the stated transaction boundary. External resources and marker retention still require separate design.
20.A duplicate-request marker is inserted first in a separate commit, then the business effect crashes before committing. What incorrect outcome can a retry produce?
Show answer and explanation
- Only a larger marker table
- A guaranteed duplicate successful effect
- Skipping an effect that never completed
- A guarantee marking first always yields exactly-once work
Answer: Skipping an effect that never completed
A committed marker can suppress unfinished work if not atomically related to the effect or managed by a sound lifecycle protocol. 'Mark first' and 'mark last' have different crash gaps.
21.An application performs an atomic database commit but loses the reply to COMMIT. What is the client's state of knowledge?
Show answer and explanation
- The transaction definitely never reached the server.
- A guarantee retrying under a new identity cannot repeat work
- The outcome may be unknown without further protocol evidence.
- The transaction definitely aborted.
Answer: The outcome may be unknown without further protocol evidence.
Lost responses can make commit outcome ambiguous. Use stable operation identity, outcome lookup, or another appropriate recovery mechanism instead of infer noncommitment from silence.
22.An API returns 'accepted' after placing a request in volatile memory. Clients interpret it as durably committed. What must be aligned?
Show answer and explanation
- Only the number of worker threads
- Only the response's HTTP text
- A guarantee success-shaped responses imply durable business state
- The acknowledgment's actual persistence and outcome semantics
Answer: The acknowledgment's actual persistence and outcome semantics
Acceptance, durability, commitment, and application are distinct milestones. Define what the response promises and ensure implementation and clients use the same meaning.
23.A distributed transaction updates shards A and B. Each local transaction is serializable, but no mechanism coordinates their combined decision. What is not established by local serializability alone?
Show answer and explanation
- A single atomic, globally isolated transaction across both shards
- The local transaction's stated isolation behavior
- The existence of two independent storage boundaries
- The possibility of a failure between local commits
Answer: A single atomic, globally isolated transaction across both shards
Local guarantees do not automatically compose into global atomicity and isolation. The cross-shard protocol must define decision, visibility, conflicts, and recovery.
24.A two-phase commit participant durably votes prepared. The coordinator's final decision is temporarily unavailable. Why can the participant not simply choose its preferred outcome under the atomicity contract?
Show answer and explanation
- Only the transaction ID is long.
- A guarantee prepared means independently committed
- Other participants may already rely on a different final decision.
- Only the participant is busy.
Answer: Other participants may already rely on a different final decision.
Preparation creates an obligation in a global decision protocol. Unilateral resolution without a valid recovery rule can conflict with a decision already made elsewhere.
25.A coordinator receives an abort vote from one required participant. Under an all-participants-must-prepare commit rule, what decision is permitted?
Show answer and explanation
- A guarantee local success at one shard makes global commit valid
- Abort rather than commit that transaction
- Count the abort as a prepare vote
- Commit using only the affirmative participants
Answer: Abort rather than commit that transaction
The supplied commit condition requires every participant's preparation. One required abort prevents that condition, subject to the protocol's decision and recovery rules.
26.All participants have prepared, but the coordinator crashes before recording any final decision. What must recovery establish?
Show answer and explanation
- The valid decision according to durable protocol state
- That preparation alone means every effect was already visible
- A guarantee every participant may resolve independently
- Only the participants' names
Answer: The valid decision according to durable protocol state
Prepared state and a final decision are different. Recover using the actual coordinator or consensus-backed decision protocol and its presumed-outcome rules, not an invented assumption about visibility.
27.A coordinator sends COMMIT to one participant before the required final decision record is durable, then loses its state. What protocol risk exists?
Show answer and explanation
- Only a duplicate message
- Only slower disk utilization
- A guarantee sending a decision makes it durably recoverable everywhere
- A participant can commit while recovery cannot preserve that decision.
Answer: A participant can commit while recovery cannot preserve that decision.
The decision record and message order must satisfy the protocol's crash-recovery argument. Otherwise different participants may resolve inconsistently after coordinator loss.
28.A coordinator durably records COMMIT, then crashes before notifying any participant. What should valid recovery propagate?
Show answer and explanation
- An arbitrary abort because no reply was sent
- Only a new transaction ID
- A guarantee a crash erases durable decisions
- The recorded commit decision
Answer: The recorded commit decision
Notification loss does not undo the durable decision. Recovery must preserve and distribute the valid recorded outcome under the protocol.
29.A participant receives duplicate COMMIT messages for the same completed transaction. What should its completion handling support?
Show answer and explanation
- A guarantee duplicate delivery creates a new global decision
- Choosing abort on the second message
- Repeating every business effect as a new transaction
- Consistent idempotent resolution for that transaction identity
Answer: Consistent idempotent resolution for that transaction identity
Protocol retries can duplicate decision messages. Tie handling to stable transaction identity and state so duplicates do not change an already resolved outcome.
30.A delayed ABORT for a transaction arrives after that same transaction has validly committed. What should the participant avoid?
Show answer and explanation
- Following the protocol's error and recovery path
- Recording evidence of a conflicting decision
- Reversing the committed outcome based only on the stale message
- Checking the message's context
Answer: Reversing the committed outcome based only on the stale message
A valid decision is not replaced by arbitrary later arrival. Detect inconsistent or stale messages and preserve the atomicity protocol's established outcome.
31.A prepared transaction retains locks while awaiting resolution. What operational effect should monitoring track?
Show answer and explanation
- Only the coordinator's hostname
- Only the number of SQL characters
- A guarantee preparation releases every resource immediately
- Blocked work and resource retention
Answer: Blocked work and resource retention
Prepared-state lifecycle can affect availability, storage reclamation, and other transactions. Track unresolved age, ownership, and a valid recovery path rather than abandon prepared work.
32.An operator deletes prepared-state records to remove a dashboard warning, without resolving the global transaction. What is the danger?
Show answer and explanation
- A guarantee deleting evidence resolves the transaction
- Only lower disk usage
- Only a cosmetic report change
- Losing information required for atomic recovery
Answer: Losing information required for atomic recovery
Protocol state is not disposable logging. Resolve obligations through the supported recovery procedure and preserve the decision information needed to maintain consistency.
33.A distributed commit protocol guarantees all-or-nothing outcome but permits concurrent transactions to observe incompatible snapshots. What additional property needs a separate argument?
Show answer and explanation
- Only atomic commitment again
- Only the number of participants
- The promised global isolation level
- A guarantee atomic commit automatically implies serializability
Answer: The promised global isolation level
Atomicity and isolation are distinct dimensions. A global decision protocol alone does not establish the serialization or visibility relations required by the application.
34.A consensus-backed coordinator makes its decision record fault tolerant. What participant-side issue still needs handling?
Show answer and explanation
- Prepared-state durability and correct decision application
- A guarantee replicating the coordinator fixes every participant failure
- Only the coordinator's replica count
- Only its leader-election timeout
Answer: Prepared-state durability and correct decision application
A robust decision service is one component. Participants still need compatible prepare, persistence, identity, application, and recovery semantics for the complete transaction guarantee.
35.A saga reserves a workshop slot, then a later step fails. Its compensation releases the slot in a new operation. What should the consistency claim distinguish?
Show answer and explanation
- Only the number of service calls
- Compensating actions from one invisible atomic rollback
- A guarantee compensation erases every external observation
- Only the slot's numeric ID
Answer: Compensating actions from one invisible atomic rollback
A saga can manage a business process through visible intermediate states and compensations. That is different from a transaction whose effects were never externally committed.
36.A compensation credits an account after a prior debit, but a user already observed and acted on the temporary reduced balance. What cannot be claimed from the final balance alone?
Show answer and explanation
- That intermediate observation can matter
- That the entire process was externally atomic
- That a later credit can restore a numeric balance
- That the debit and credit were separate events
Answer: That the entire process was externally atomic
Restoring a state value does not undo every intervening observation or action. Define acceptable intermediate behavior and compensation limits explicitly.
37.A saga compensation can itself fail or time out. What must the workflow's recovery model include?
Show answer and explanation
- A guarantee every compensation always completes immediately
- Only a success-path diagram
- Only the original step's request payload
- Durable compensation state and retry or escalation semantics
Answer: Durable compensation state and retry or escalation semantics
Compensation is another distributed operation with failure and ambiguity. Track its identity, outcome, and unresolved obligations instead of assuming rollback is effortless.
38.A compensation command is retried after its successful reply is lost. What property helps avoid applying the compensation twice?
Show answer and explanation
- Only a longer retry delay
- Only a new unrelated request key per attempt
- A suitable effect identity and idempotent handling
- A guarantee compensation effects cannot be duplicated
Answer: A suitable effect identity and idempotent handling
Recovery actions need the same careful identity and outcome semantics as forward actions. A duplicated compensation can create a new business error.
39.A cross-shard workflow debits A, then credits B in separate commits. Readers may see the intermediate state. What should the API guarantee state?
Show answer and explanation
- The actual visibility and recovery semantics
- Only the final intended total
- Only that both functions have the word transaction
- A guarantee eventual intent implies instantaneous atomicity
Answer: The actual visibility and recovery semantics
A process with separate commits can expose intermediate effects. Specify what users may observe and how failures resolve; do not label it atomic without a supporting protocol.
40.A reservation expires while a delayed finalization request is in flight. What must finalization atomically validate?
Show answer and explanation
- A guarantee every prior reservation remains valid forever
- The reservation's current lifecycle state and authority
- Only the finalization's arrival timestamp
- Only the original reservation response
Answer: The reservation's current lifecycle state and authority
A prior successful hold does not authorize a later transition after expiry or cancellation. Couple state validation with the effect to prevent stale finalization.
41.A hold has version 4. It expires and is recreated as version 5 under the same display name. A delayed release targets version 4. What should prevent it from releasing version 5?
Show answer and explanation
- A guarantee repeated names identify the same hold lifetime
- Generation-aware conditional state transition
- Only matching display names
- Only the latest arrival order
Answer: Generation-aware conditional state transition
A lifecycle generation distinguishes incarnations. Validate the intended version and permitted transition at the point where the release takes effect.
42.An outbox row is committed with a business update, then a publisher delivers it twice after losing an acknowledgment. What additional consumer property may be needed?
Show answer and explanation
- Only atomic outbox insertion
- A guarantee an outbox eliminates all duplicate delivery
- Only a larger publisher batch
- Duplicate-safe effect processing
Answer: Duplicate-safe effect processing
An outbox can close a durable-intent gap while still delivering at least once. Consumer or external effect semantics must handle duplicates where the contract requires uniqueness.
43.A consumer commits output effects and its source checkpoint separately. It advances the checkpoint first, then crashes before output commit. What can recovery do incorrectly?
Show answer and explanation
- Only increase processing latency
- Only replay already committed output
- A guarantee a checkpoint contains the missing output effects
- Skip work whose output never became durable
Answer: Skip work whose output never became durable
The checkpoint can move beyond completed work. Couple the relevant state or use a sound replay and reconciliation design matching the promised delivery semantics.
44.The same consumer commits effects first and crashes before its checkpoint. What must replay handle?
Show answer and explanation
- A guarantee committing effects automatically advances every checkpoint
- A guarantee the event is permanently lost
- Only a changed partition assignment
- Possible repeated application of the committed effect
Answer: Possible repeated application of the committed effect
Replaying from the old checkpoint can redeliver completed work. Atomicity or duplicate-safe effect handling closes that different failure gap.
45.A transaction updates a database and an asynchronously maintained search index. What does the database commit alone guarantee about the index?
Show answer and explanation
- Only that the search process is alive
- That every index replica already reflects it
- That index queries are automatically part of the transaction
- No immediate index update without an additional mechanism
Answer: No immediate index update without an additional mechanism
An external projection has its own update and visibility protocol. Define freshness and failure behavior rather than infer synchronous index consistency from the source commit.
46.A client writes version 18, then reads an async projection that reports applied-through 16. What should a read-after-write path use?
Show answer and explanation
- A guarantee every request after a write sees the projection update
- Only a fixed arbitrary delay
- Only the projection's process ID
- A version-aware wait, route, or explicit stale-result contract
Answer: A version-aware wait, route, or explicit stale-result contract
Projection position makes lag interpretable but does not remove it. Enforce or qualify the desired visibility relation using the actual version boundary.
47.A cache fill reads old version 7 before a writer commits version 8. The writer invalidates the cache, then the old fill inserts version 7. What consistency gap remains?
Show answer and explanation
- A stale-fill race after invalidation
- Only a longer cache key
- Only a duplicate invalidation message
- A guarantee invalidate-after-write prevents every stale insertion
Answer: A stale-fill race after invalidation
A delayed fill can repopulate old data after invalidation. Use an appropriate version, generation, synchronization, or freshness protocol for the required guarantee.
48.A cache insertion is conditional on its version being at least the cache's retained invalidation generation. A fill for generation 7 arrives after generation 8 was recorded. What should happen?
Show answer and explanation
- Replace generation 8 because the fill arrived later.
- Erase the invalidation generation.
- Reject that stale fill under the supplied rule.
- A guarantee all fills are newer than all invalidations
Answer: Reject that stale fill under the supplied rule.
The rule compares authoritative generations rather than arrival order. Preserve the generation across invalidation so a delayed old fill cannot silently revive stale state.
49.A transaction's check uses a cache while its write uses current database state, and the cache can lag. What must the invariant argument establish?
Show answer and explanation
- That the validated condition is current at the atomic effect boundary
- A guarantee successful reads from any source validate current invariants
- Only the query's response speed
- Only the cache's average hit rate
Answer: That the validated condition is current at the atomic effect boundary
A stale precheck cannot by itself enforce a current invariant. Revalidate or use a suitable conditional or transaction mechanism over the authoritative state.
50.A unique username is checked with SELECT, then inserted in another transaction. Two clients race. What storage-side property can enforce the uniqueness invariant?
Show answer and explanation
- Only the preliminary SELECT
- Only distinct client request times
- An appropriate unique constraint or equivalent atomic rule
- A guarantee checking first reserves the name
Answer: An appropriate unique constraint or equivalent atomic rule
An independent precheck can race. Enforce the invariant atomically where the records are created and handle the possible conflict according to the API contract.
51.A global name must be unique, but each shard enforces uniqueness only within its own partition. What remains necessary?
Show answer and explanation
- A guarantee local uniqueness across arbitrary shards is global uniqueness
- Only longer names
- Only local unique indexes
- A sound global allocation or routing invariant
Answer: A sound global allocation or routing invariant
Global uniqueness needs a relation among shard placement and ownership, or another suitable coordination mechanism. Separate local constraints do not automatically compose.
52.All records for one unique key route deterministically to one authoritative shard under a correct epoch protocol. How can that help enforce uniqueness?
Show answer and explanation
- It eliminates every possible routing failure by definition.
- It places conflicting creations under one atomic authority.
- It permits independent authorities for the same key without coordination.
- It makes timestamps globally exact.
Answer: It places conflicting creations under one atomic authority.
A valid partitioning invariant can localize a constraint. Routing changes, stale maps, recovery, and concurrent ownership still need their own correctness argument.
53.A shard migration lets old and new owners both accept conditional updates using independent version counters. What must be preserved?
Show answer and explanation
- A guarantee two local CAS implementations compose into one global CAS
- Only each owner's local counter monotonicity
- Only matching key names
- One sound authority and version relation across handoff
Answer: One sound authority and version relation across handoff
A conditional update is scoped to its authority and history. Migration must prevent incompatible concurrent ownership or define a sound coordination protocol across the boundary.
54.A backfill copies version 5 after change capture already applied version 8 at the destination. What should version-aware application prevent?
Show answer and explanation
- Only a repeated copy operation
- Regression to the older copied state
- A guarantee copy arrival order is authoritative freshness
- Only larger network packets
Answer: Regression to the older copied state
Backfill and live updates can interleave. Compare the appropriate source version or watermark and retain delete and lifecycle semantics so stale copy data cannot overwrite newer state.
55.A backfill represents absence by no row and omits a deletion event that occurred after its snapshot. What can happen at the destination?
Show answer and explanation
- Only the destination's sort order changes.
- Every source delete is automatically inferred.
- A guarantee a complete insert copy carries future deletions
- A deleted record can remain or reappear.
Answer: A deleted record can remain or reappear.
Replication of state changes needs defined deletion and snapshot boundaries. Absence in one scan is not a substitute for a valid deletion history across concurrent changes.
56.A report reads shard A at one snapshot and shard B at a later snapshot while a cross-shard transfer commits. What can the combined result contain?
Show answer and explanation
- A guarantee two individually valid snapshots are one snapshot
- Only a guaranteed consistent total
- Only data from the earlier snapshot
- A fractured view inconsistent with one intended global snapshot
Answer: A fractured view inconsistent with one intended global snapshot
Independent snapshot positions can include one side of a related update and omit another. Use or qualify an appropriate global visibility contract.
57.A total is 100 units split across two shards. A transfer moves 10 from A to B. A report sees A after debit and B before credit. What apparent total results under this observation?
Show answer and explanation
- 10
- 100
- 90
- 110
Answer: 90
The mixed observation includes the −10 but not the +10, giving 100−10=90. The intended atomic transfer's completed total remains 100.
58.The same transfer is observed with A before debit and B after credit. What apparent total can be reported?
Show answer and explanation
- 100
- 0
- 110
- 90
Answer: 110
The mixed observation includes the +10 without the −10, giving 100+10=110. Independent read positions can create either direction of inconsistent aggregate.
59.A database snapshot covers one database, but the report also reads an external service's mutable state. What scope should the report claim?
Show answer and explanation
- Only the external service's current value
- A guarantee snapshots automatically extend to unrelated services
- A global atomic view merely because one input is transactional
- Only the consistency actually established across its inputs
Answer: Only the consistency actually established across its inputs
A local snapshot does not bind independent external observations. Coordinate, version, or qualify the combined report according to the intended cross-system consistency.
60.A read-only transaction never writes, but it reads values from two incompatible committed moments under its isolation contract. Can it still return an inconsistent business view?
Show answer and explanation
- Yes; absence of writes does not guarantee a coherent multi-read view.
- No; all read-only code is serializable by definition.
- No; committed data always forms one snapshot across statements.
- Only write transactions can observe anomalies.
Answer: Yes; absence of writes does not guarantee a coherent multi-read view.
Read-only operations can require meaningful snapshot and dependency guarantees. State the actual isolation and cross-source scope instead of equating read-only with globally consistent.
61.A service chooses a transaction isolation level by name without checking the database's documented semantics. What should implementation review establish?
Show answer and explanation
- Only that the level name sounds strict
- A guarantee identical level names always mean identical observable behavior
- Only a larger connection pool
- The actual guarantees and retry behavior of that implementation
Answer: The actual guarantees and retry behavior of that implementation
Implementations can provide different guarantees and special cases within a named level. Validate the actual read, write, predicate, and failure semantics needed by the application.
62.A transaction reads its own earlier write before commit. Why is that not, by itself, a dirty read from another transaction?
Show answer and explanation
- Only the row's numeric ID matters.
- Every uncommitted value has necessarily come from another transaction.
- The value is from the same transaction's work.
- A guarantee own writes are already committed globally.
Answer: The value is from the same transaction's work.
Isolation rules often distinguish a transaction's own changes from another transaction's uncommitted changes. Specify the actual database behavior rather than conflate the two.
63.A transaction requires one stable snapshot but sends each query through unrelated auto-committed connections. What must the application establish?
Show answer and explanation
- Only identical SQL text
- A real shared transaction or compatible snapshot context
- Only one request-scoped log ID
- A guarantee one application function creates one database transaction
Answer: A real shared transaction or compatible snapshot context
Connection and transaction boundaries matter. Multiple auto-committed statements do not automatically share a snapshot or atomic outcome merely because one application request issued them.
64.A connection is returned to a pool with an unresolved transaction. The next request reuses it. What lifecycle property should the pool enforce?
Show answer and explanation
- A guarantee pooled connections forget all transaction state automatically
- Only the connection's idle duration
- Defined cleanup or isolation of transaction state before reuse
- Only a new log label
Answer: Defined cleanup or isolation of transaction state before reuse
Session state can carry across requests. Ensure commit, rollback, reset, or another valid cleanup policy prevents unintended transaction inheritance.
65.A transaction holds a lock while awaiting an unrelated slow HTTP call. What operational risk should the design assess?
Show answer and explanation
- A guarantee network waiting consumes no transactional resources
- Only the database connection's name
- Extended lock duration and blocked concurrent work
- Only the HTTP response's grammar
Answer: Extended lock duration and blocked concurrent work
External waits can extend resource retention and failure exposure. Choose transaction boundaries and durable workflows that satisfy the invariant without unnecessary long-held state.
66.T1 locks resource A then waits for B. T2 locks B then waits for A. What dependency exists?
Show answer and explanation
- A wait-for cycle
- Only a missing unique constraint
- A guarantee both transactions can complete without intervention
- A guaranteed serial execution
Answer: A wait-for cycle
Each transaction waits for the other's held resource. Deadlock handling or prevention must break the cycle while preserving transaction semantics.
67.All transactions acquire the same class of locks in one global resource order and obey that rule. What problem can this help prevent within that lock class?
Show answer and explanation
- Cycles caused by inconsistent acquisition order
- Every possible serialization anomaly
- Every external-service timeout
- A guarantee no transaction ever waits
Answer: Cycles caused by inconsistent acquisition order
A consistent acquisition order can eliminate that source of circular wait under the stated model. It does not establish all isolation or progress properties across other resources.
68.A deadlock detector aborts one transaction. What should the application do before retrying its logical operation?
Show answer and explanation
- Follow the actual rollback and full-retry contract safely
- Only change the request's display ID
- Only repeat the last effect using old local state
- A guarantee every external action from the aborted attempt vanished
Answer: Follow the actual rollback and full-retry contract safely
A victim abort can require new reads and recomputation. Preserve logical-operation identity and account for side effects outside the database transaction.
69.A range-lock strategy protects rows currently in a quota group but not insertion of new group members. What must the quota invariant consider?
Show answer and explanation
- Only updates to currently locked rows
- Membership changes that alter the protected aggregate
- Only the number of locks acquired
- A guarantee a set of row locks protects every possible future row
Answer: Membership changes that alter the protected aggregate
An aggregate constraint can change through inserts, deletes, or membership updates. The protection must cover every state transition relevant to the predicate.
70.Two services each validate 'no active deployment exists,' then insert different active deployment rows. Row IDs are unique and writes do not conflict. What invariant can still fail?
Show answer and explanation
- Only timestamp formatting
- At most one active deployment
- Uniqueness of the two row IDs
- A guarantee unique primary keys enforce every business constraint
Answer: At most one active deployment
Identity uniqueness does not enforce a predicate about how many qualifying records exist. Use a suitable atomic constraint or coordination mechanism for the active-deployment rule.
71.A single durable record identifies the current active deployment. An atomic compare-and-swap changes it only from a supplied version. What should its correctness argument include?
Show answer and explanation
- A guarantee one CAS automatically makes external rollouts atomic
- The authority, version lifecycle, and complete effect boundary
- Only the atomic primitive's name
- Only the number of callers
Answer: The authority, version lifecycle, and complete effect boundary
A conditional record update can coordinate state, but the full workflow must connect that decision to deployment effects, failures, and recovery. Do not infer cross-system atomicity from one local primitive.
72.A global resource capacity is 100. The system assigns nonoverlapping spend budgets of 60 to shard A and 40 to shard B, each enforcing its remaining budget atomically. What total-allocation bound follows if no other path allocates?
Show answer and explanation
- At most 60
- Unlimited, despite the stated enforcement
- At most 100
- At most 40
Answer: At most 100
The sum of the disjoint budgets is 60+40=100. The bound relies on correct local enforcement, durable budget ownership, and no double-spend during budget changes or recovery.
73.Shard A has exhausted its assigned budget while shard B has 20 unused units. What tradeoff can a decentralized budget scheme face?
Show answer and explanation
- Every local request must succeed because capacity exists elsewhere.
- Unused global capacity may be unavailable locally until safe transfer.
- The global capacity must have been exceeded.
- A guarantee partitioned budgets remove all availability tradeoffs
Answer: Unused global capacity may be unavailable locally until safe transfer.
Partitioning rights can preserve a bound without per-operation global coordination, but rights may be stranded. A transfer protocol must preserve conservation and authority.
74.A budget transfer credits B before A's debit is durably recorded, and A may crash and retain its old budget. What invariant is endangered?
Show answer and explanation
- Only the number of shards
- A guarantee transferring counters independently cannot duplicate rights
- Conservation of allocation rights
- Only the transfer's log ordering display
Answer: Conservation of allocation rights
A safe rights-transfer protocol must prevent the same capacity from being spendable at both places. Atomicity, durable intent, and recovery semantics matter for the transfer itself.
75.Two replicas each see an empty set, add a distinct active reservation, and later merge by set union. The contract allows at most one active reservation. What does convergence alone fail to preserve?
Show answer and explanation
- Deterministic union of those sets
- The fact that both additions can be retained
- The cardinality invariant
- Eventual agreement on the merged content under the model
Answer: The cardinality invariant
A convergent merge can consistently produce an invalid business state. Invariant preservation needs suitable coordination, rights, conflict semantics, or a narrower operation model.
76.An invariant must hold only at committed boundaries, while a transaction temporarily violates it internally before restoring it. What should checking distinguish?
Show answer and explanation
- Only the transaction's final log length
- Internal intermediate state from externally committed state
- A guarantee all invariants always have identical observation scope
- Every temporary local value as a committed defect
Answer: Internal intermediate state from externally committed state
Specify where the requirement applies. Atomicity can hide internal intermediate states from external observers, but internal checks may enforce other distinct constraints.
77.A transaction emits an external event describing its intermediate invalid state before committing a restored final state. What boundary issue appears?
Show answer and explanation
- The intermediate state escaped the intended atomic visibility boundary.
- Only the event's timestamp is relevant.
- A guarantee an eventual valid state erases external observations
- The final commit necessarily includes the event atomically.
Answer: The intermediate state escaped the intended atomic visibility boundary.
A local transaction cannot hide side effects it sends outside its boundary. Publish appropriate committed information through a mechanism aligned with the intended visibility and recovery semantics.
78.A business rule requires total debits equal total credits for each committed transfer. What checker is stronger than comparing only one final account balance?
Show answer and explanation
- A guarantee any nonnegative balance proves conservation
- Only the number of HTTP replies
- Only the latest balance of one account
- A transfer-identity ledger of both committed sides
Answer: A transfer-identity ledger of both committed sides
A final balance can hide duplicates, omissions, and offsetting errors. Trace the required relationship for each logical transfer with proper outcome and identity accounting.
79.A transfer ledger starts with total 500 and records committed net changes +20, −15, and −5 from external inflows and outflows. What total should reconciliation expect?
Show answer and explanation
- 540
- 500
- 480
- 520
Answer: 500
The net change is 20−15−5=0, so the expected total remains 500. Internal transfers should be handled according to their separate conservation rule.
80.A reconciliation job finds a discrepancy and blindly overwrites the destination with a stale source snapshot while live updates continue. What should a repair protocol protect?
Show answer and explanation
- Only the repair's completion time
- A guarantee a repair label makes all overwrites safe
- Only matching row counts
- Version order and concurrent legitimate changes
Answer: Version order and concurrent legitimate changes
Repair is another writer. It needs a justified authority, version, and concurrency model so it does not regress newer state or repeat effects.
81.An audit compares row counts and finds both databases have 1,000 rows. What consistency property does that alone fail to establish?
Show answer and explanation
- Equality of the two observed row counts
- The fact that both counts were measured
- Equality of the intended records and values
- The possibility of deeper reconciliation
Answer: Equality of the intended records and values
Equal counts can hide different identities, incorrect values, and missing records offset by extras. Compare the data relations relevant to the actual migration or replication contract.
82.A transaction validates an amount is in [0,100] only in a UI. Another API bypasses the UI and writes 150. What must invariant enforcement cover?
Show answer and explanation
- Only the field's display format
- A guarantee client validation enforces database state globally
- Every authoritative write path
- Only the UI's successful tests
Answer: Every authoritative write path
A state invariant can be violated through any unprotected mutation path. Enforce it at an appropriate shared boundary and keep user-facing validation for feedback rather than sole authority.
83.A relation requires every child to refer to an existing parent. A concurrent parent deletion races a separate child-creation precheck. What should the integrity design ensure?
Show answer and explanation
- Atomic enforcement of the relevant reference relation
- A guarantee checking existence once reserves the parent forever
- Only distinct child IDs
- Only a successful earlier parent lookup
Answer: Atomic enforcement of the relevant reference relation
Existence checks can become stale. Use an appropriate storage constraint or coordinated lifecycle protocol that covers concurrent creation and deletion under the actual scope.
84.A storage constraint protects one database, but an application copies related rows to an external store with no equivalent lifecycle rule. What should the system argument avoid?
Show answer and explanation
- Extending the local constraint automatically to the external store
- Identifying separate storage boundaries
- Checking external deletion and update behavior
- Reporting the local constraint's actual scope
Answer: Extending the local constraint automatically to the external store
Integrity does not automatically transfer with data. Replication, deletion, identity, and concurrency rules must preserve the intended relation at each destination or qualify its consistency.
85.A transaction commits rows that an old application version cannot parse during a rolling deployment. What should the rollout coordinate?
Show answer and explanation
- Only transaction isolation level
- Only the newest binary's tests
- Data-format compatibility with all participating versions
- A guarantee atomic commit makes every reader compatible
Answer: Data-format compatibility with all participating versions
Transaction correctness does not establish schema compatibility. Define safe format introduction, activation, readers, and rollback behavior during mixed-version operation.
86.A binary rollback restores old code after new code has written a new record format. What additional recovery concern remains?
Show answer and explanation
- A guarantee rolling back code rolls back all committed data
- Only the old binary's checksum
- Compatibility or migration of persisted new-format data
- Only the deployment timestamp
Answer: Compatibility or migration of persisted new-format data
Code and durable data have different lifecycles. A rollback plan needs a valid relation to already committed data rather than assume earlier binaries can interpret it.
87.A schema migration backfills a derived field using an outdated formula while live writes use a new formula. What must the data contract identify?
Show answer and explanation
- A guarantee equal field names imply equal semantics
- The derivation version and update ordering
- Only whether every row has a nonnull value
- Only the new column's name
Answer: The derivation version and update ordering
A field's meaning can change while its shape remains the same. Track derivation semantics and concurrent backfill behavior, then validate values against the intended version.
88.A snapshot transaction reads at a defined historical version. It returns an older committed value even though a newer write exists now. What should its result claim distinguish?
Show answer and explanation
- A guarantee a snapshot always means the newest state
- Correct historical visibility from a promise of latest state
- Only the current wall-clock time
- Every old value as a dirty read
Answer: Correct historical visibility from a promise of latest state
A consistent historical snapshot can be intentionally stale. Specify the read target and do not conflate snapshot coherence with latest-value guarantees.
89.A user action needs a stable multi-page result over a changing dataset. What should its continuation context identify?
Show answer and explanation
- A guarantee offset pagination preserves one view automatically
- Only a new timestamp for every page
- Only the last page's row count
- The relevant snapshot and query semantics
Answer: The relevant snapshot and query semantics
Pagination over mutable data can skip or duplicate records or mix versions. Bind pages to an appropriate snapshot and ordering contract where a stable view is required.
90.A transaction holds a snapshot for hours while writers continue. What resource behavior should be monitored under an MVCC design retaining needed old versions?
Show answer and explanation
- Only the number of result columns
- Only the reader's log level
- Retention of historical versions and related pressure
- A guarantee long readers never affect storage or cleanup
Answer: Retention of historical versions and related pressure
A retained snapshot can require old versions to remain available. Assess the actual implementation's cleanup, storage, and resource effects without assuming all readers are operationally free.
91.A database enforces serializable execution but the application never checks affected-row counts from conditional updates. A failed reservation is treated as success. What still fails?
Show answer and explanation
- Application interpretation of the operation's outcome
- A guarantee strong isolation fixes ignored error results
- Only the query planner's speed
- The database's stated isolation guarantee necessarily
Answer: Application interpretation of the operation's outcome
A correct database result still needs correct application handling. Check success, conflict, and affected-row semantics before acknowledging a business effect.
92.A conditional update returns zero affected rows because the expected version is stale. What should the application avoid?
Show answer and explanation
- Re-reading and recomputing as appropriate
- Returning an explicit conflict under the API contract
- Acknowledging the intended replacement as completed
- Recording that no row changed
Answer: Acknowledging the intended replacement as completed
The failed condition means that effect did not occur under the supplied rule. Do not confuse a successfully executed SQL statement with a successful business state transition.
93.A constraint rejects a transaction. The application catches the exception and returns success without committing an alternative. What evidence should a test inspect?
Show answer and explanation
- The actual committed state and API outcome relation
- A guarantee handled exceptions mean the business action succeeded
- Only the absence of a server crash
- Only whether the handler returned JSON
Answer: The actual committed state and API outcome relation
Error handling can hide a failed effect from clients. Test that acknowledgments correspond to the specified durable outcome, including conflict and rejection paths.
94.A transaction benchmark reports only committed attempts, omitting serialization retries. What performance evidence is missing?
Show answer and explanation
- A guarantee omitted attempts consume no resources
- Only the database's advertised level name
- Only the fastest successful SQL statement
- Logical-operation latency, retry work, and failure outcomes
Answer: Logical-operation latency, retry work, and failure outcomes
Retry overhead affects cost and tail latency. Define whether metrics concern attempts or logical operations and include all relevant work and outcomes.
95.Three attempts of one logical operation take 10, 15, and 20 ms, separated by two 5 ms backoffs. The third succeeds. What end-to-end duration follows without other overhead?
Show answer and explanation
- 30 ms
- 55 ms
- 20 ms
- 45 ms
Answer: 55 ms
Total duration is 10+5+15+5+20=55 ms. Successful-attempt time alone would omit earlier work and backoff experienced by the caller.
96.A retry policy gives each new attempt a full 100 ms budget even though the logical request's 100 ms deadline has nearly expired. What should be propagated?
Show answer and explanation
- A guarantee retries cannot exceed the original deadline
- Only a fresh unrelated deadline per attempt
- Only the number of attempts
- The remaining logical-operation budget
Answer: The remaining logical-operation budget
Attempt budgets must fit the actual end-to-end policy. Track elapsed work, backoff, and reserves rather than reset the user's budget with each retry.
97.A transaction cancellation request arrives after COMMIT has completed. What should the API define?
Show answer and explanation
- Whether any new compensating action is possible, rather than imply the commit vanished
- Only the network connection's state
- A guarantee cancellation reverses every completed durable effect
- Only the canceled request's spelling
Answer: Whether any new compensating action is possible, rather than imply the commit vanished
Cancellation has a lifecycle boundary. A completed commit needs a defined later operation if business reversal is supported; dropping the client connection does not itself undo it.
98.A test checks only final balances after concurrent transfers and omits operation results. What history defect can remain hidden?
Show answer and explanation
- A false success or duplicated logical operation whose totals happen to offset
- Only the final total itself
- Only the number of accounts
- A guarantee correct final totals validate every acknowledged operation
Answer: A false success or duplicated logical operation whose totals happen to offset
End-state invariants are useful but not complete histories. Record invocation, outcome, identity, and relevant state transitions for the actual correctness claim.
99.A concurrency test sees one schedule pass. What stronger validation can probe a small invariant-critical algorithm?
Show answer and explanation
- Explore relevant interleavings against an independent state model.
- Only repeat the same deterministic order.
- Assume the one schedule represents every execution.
- A guarantee adding threads automatically explores all histories
Answer: Explore relevant interleavings against an independent state model.
Small exhaustive or systematic models can reveal schedules random testing misses. Their assumptions and relation to the implementation still need review.
100.A distributed transaction proof assumes no message duplication, while the deployed transport can retry. What must be added to the correctness argument?
Show answer and explanation
- A guarantee retries preserve every protocol automatically
- Only a larger transaction counter
- Only faster message delivery
- Duplicate-message and identity handling under the real transport model
Answer: Duplicate-message and identity handling under the real transport model
A protocol must handle the actual transport's duplication, delay, loss, and recovery semantics. A narrower proof cannot silently cover omitted behaviors.
101.A candidate must justify a transaction boundary. Which response is strongest?
Show answer and explanation
- Assume retries cannot affect external services.
- Wrap two functions in one method and call it atomic.
- Rely only on an isolation-level label.
- Name the invariant, authority, concurrent histories, durable decision, visibility, and recovery behavior.
Answer: Name the invariant, authority, concurrent histories, durable decision, visibility, and recovery behavior.
A sound transaction design connects the required business relation to the actual storage and protocol boundaries, including failure and observation semantics.