↗MLabsTALENT PARTNERSLet’s talk hiring ↗
← THE HIRING NOTEBOOK / BLOCKCHAIN & RUST

A Rust interview that tests cancellation and shutdown safety

Assess production Rust engineers with an async worker review covering partial progress, cancellation, shutdown and tests that expose lost work.

By MLabs Talent Partners · · 5 min read

A Rust candidate can explain ownership and still miss what happens when an asynchronous operation is interrupted halfway through. For a team running network services, indexers or infrastructure workers, that gap can matter more than fluency with a difficult lifetime annotation. A focused cancellation review offers a practical way to investigate it.

The exercise below is intended for production Rust roles that use asynchronous processing. It is not a universal test for every Rust vacancy, and it does not establish blockchain protocol expertise. It examines how the candidate accounts for partial progress when work is cancelled, retried or shut down.

Choose a worker your interviewers can explain

Use a fictional service that receives work, writes a framed message to a connection and records completion. Provide a short implementation with a shutdown signal and a timeout. State what the receiving service does, how acknowledgement works and whether the job can be retried. Without those details, an answer about safe shutdown is mostly a guess.

Define the requirement in observable terms. After a restart, the service must be able to distinguish completed work from work needing investigation or retry. If the exercise assumes a downstream operation is idempotent, say so. If it is not, do not expect the candidate to invent a guarantee from the local code.

Keep the code small enough for a joint review in around an hour. Use a prepared dependency lockfile and runnable tests if implementation is included. Avoid making unfamiliar project setup consume the time intended for reasoning.

Walk through a cancellation point

Ask the candidate to trace a job from receipt to acknowledgement. At each await point, ask what state exists locally and what may already have happened elsewhere. Then introduce a timeout while a message is being written. What does dropping the pending operation mean for the work already performed?

Tokio's select documentation explains cancellation safety and lists methods such as read_exact and write_all that are not cancellation safe in the described usage. Give candidates access to the documentation for the project's pinned version. The assessment should reward checking the contract and applying it, rather than recalling a list from memory.

Ask whether recreating the future is equivalent to continuing the interrupted operation. Could bytes already have been consumed or sent? Where is progress recorded? A sound answer distinguishes local future cancellation from reversal of external effects. Neither memory safety nor an error return automatically undoes a partially completed protocol exchange.

Require a state model before a patch

Have the candidate label the meaningful states: accepted, in progress, externally acknowledged and locally recorded, for example. Ask which transitions are durable and which exist only in memory. This can be a few lines on a shared document; a formal notation is unnecessary.

Now ask for one bounded improvement. A candidate might preserve progress outside the cancellable operation, change the framing approach or close an uncertain connection and reconcile the job through its identifier. Different remedies suit different protocols. Require them to explain the assumptions that make their chosen change correct.

Challenge an overly broad fix. Shielding all work from cancellation may delay shutdown indefinitely. Retrying every uncertain job may repeat an external action. Aborting immediately may leave accepted work unaccounted for. The useful skill is recognising which guarantee the service can actually offer and making uncertainty explicit when it cannot know the outcome.

Test shutdown as a sequence

Introduce a deployment termination window. Ask the candidate to describe what stops first, how already accepted work is handled and what happens when the window expires. Distinguish stopping new intake from interrupting active operations. Ask who owns spawned tasks and how the process knows whether they finished.

For an indexer or blockchain infrastructure service, you can adapt the payload to a block or transaction identifier. Keep chain-specific assumptions explicit. A correct async worker design does not prove that the candidate understands finality, reorganisation handling or consensus; assess those separately if the role requires them.

Ask what an operator should see after forced termination. Useful answers connect logs or metrics to job identity and state without claiming that a log line creates durability. The team needs enough evidence to reconcile uncertain work, not merely a reassuring shutdown message.

Ask for tests that interrupt real progress

A happy-path test will not answer the cancellation question. Request a controlled test that allows part of an operation to complete and then triggers cancellation. The candidate should state the expected bytes, state transition or retry behaviour. Prefer an explicit synchronisation point or controllable test double over a sleep that merely hopes to hit the right timing.

Include a shutdown case with queued and active work, plus a failure between remote acknowledgement and local completion recording. Ask how the test distinguishes a genuinely safe outcome from a run that simply did not exercise the vulnerable point.

EvidenceWhat to look for
Async semanticsLocates cancellation points and checks the operations' documented behaviour.
State ownershipTracks partial progress and external effects across interruption.
Protocol judgementExplains when retry is safe and when reconciliation is needed.
VerificationConstructs a deterministic interruption test with a meaningful assertion.

Use the result to make a bounded hiring decision

For an experienced production Rust hire, unresolved confusion about externally completed work may be a material gap. For a strong systems engineer moving into Rust, needing documentation for a particular API can be entirely compatible with the role. Decide which learning your team can support before comparing candidates.

Do not treat one exercise as proof of performance expertise, security assurance or overall seniority. Pair it with a past-project discussion and the specific domain assessment your vacancy needs. Our Rust hiring guide explains that separation; our benchmark interview covers a different question about measured improvements.

Close the interview by asking the candidate what remains unproven. That answer helps distinguish a plausible patch from a maintained production design, and gives your hiring team a concrete basis for a focused follow-up.

YOUR NEXT CHAPTER

Great teams don’t
happen by chance.

Tell us what you’re building. Let’s find the people to build it.

Discuss your next hire ↗