A worker reads its credential from the secret store once at start-up and never again — what does replacing that value then require?
answer
- a copy, not a connection
- the store changed, the process did not
- re-resolve then re-apply
- a restart is a reload path
- withdraw the old value last
basics
~20 sA restart, unless something inside the worker re-resolves the value and rebuilds every client constructed from it. Writing a new value into the store changes nothing inside a process that already holds a copy, and the old value must stay accepted until the last holder has moved.
solid answer
~40 sReading once at start-up means the process holds a **copy**, and a copy is not connected to the store. Writing a replacement changes the store's state and nothing inside the worker. So a replacement needs three things, in order: something must re-resolve the value; everything built from the old value — the connection pool, client objects, retry paths — must be rebuilt or re-pointed, because re-resolving only updates a variable; and the old value must keep being accepted until the last holder has done both. If nothing re-resolves, the process restart *is* the reload path. That is a legitimate design as long as it is stated, because it makes a replacement a rolling restart with a known duration rather than a change that quietly never lands.
code
pseudocode · 19 lines// at start-up: resolve once, then build things from the value
heldCredential = store.read("consumer-credential")
pool = openPool(host, port, heldCredential)
// the reload that looks right and changes nothing
onCredentialChanged():
heldCredential = store.read("consumer-credential")
// pool was built with the earlier value and is not touched here,
// so every connection it holds and opens still uses the old one
return
// the reload that actually moves the worker
onCredentialChanged():
newCredential = store.read("consumer-credential")
if newCredential == heldCredential:
return // no-op: pool left alone deliberately
heldCredential = newCredential
pool.setCredential(newCredential) // connections opened from now on use it
pool.retireIdleConnections() // old-value connections closed as they free upgo deeper
Recall that a process holds a copy of the credential it read at start-up. Changing the value in the store does not reach into that process; a restart or a deliberate re-read does.
Explain the two halves — re-resolving the value and rebuilding what was constructed from it — and why a reload that does only the first appears to succeed while nothing changes.
Show that you would treat completion as a property of the holders, keep the old value valid until the last one has moved, and state the restart duration as the real cutover window.
Decide which shape is the estate's default and what the platform owes: a stated reload contract per service, or a scheduled restart cadence that bounds how long two values must both be accepted.
## Two things happen at start-up, not one A process that resolves a credential at start-up does two separate things with it. First it **resolves** the value — one read against the store, producing a copy in the process. Then it **builds things out of that copy**: a connection pool, one or more client objects, a retry path, perhaps a background health check. Each of those captures the value it was handed. That split is the source of almost every surprise in this material, because a reload usually addresses the first and forgets the second. ## What the store shows and what the process holds Writing a replacement into the store changes the store's state. Inside the worker, nothing observes that write. The worker holds a copy it resolved at start-up and it keeps using that copy until something re-resolves the value or the process restarts. This is the direction to get right: **replacing is not withdrawing**. A new value is now available; the old value is still a valid credential at whatever system accepts it, until someone withdraws it there. A holder that never re-resolved keeps working, and you discover that only when you withdraw the old value and it breaks. ## The replacement is three steps, not one 1. **Something must re-resolve.** Either the process re-reads the value on its own, or an operator restarts it. Those are the only two ways a new value gets inside a running process. 2. **Everything built from the old value must be re-made.** Re-resolving updates a variable. The pool, the clients and the retry path still carry whatever they were constructed with, and connections already open were authenticated with the old value and will keep working on it. A reload that stops at step one looks successful and changes nothing. 3. **The old value must stay accepted until the last holder is done.** Completion is a property of the holders, not of the store. The store showing a new current version proves the write happened; it proves nothing about any consumer. ## Two shapes, and what each costs | | when a replacement is picked up | what the replacement costs | what fails if you skip it | |---|---|---|---| | resolve once, never again | at the next process start | a deliberate restart of every holder, with a known duration | the value is replaced in the store and no holder ever moves | | re-resolve and re-apply | when the process re-resolves and rebuilds | code that rebuilds clients and retires old connections | the variable changes, the pool does not, and nothing actually moves | Neither row is wrong. The failure is choosing neither — a service that has no re-resolve path *and* no scheduled restart, whose owner nonetheless believes a replacement took effect. ## Why a restart is a respectable answer If a process has no reload path, then "restart it" is the reload path, and saying so out loud converts a vague hope into a plan: a replacement becomes a rolling restart, its duration is the time to cycle the fleet, and the old value must remain valid for at least that long. What is not respectable is assuming the restart will happen by itself, because some instances live for weeks and a fleet can carry both values for far longer than anyone intended. ## The order, and the one case that inverts it For a routine replacement: put the new value in place, make the holders move, confirm they are running on it, and withdraw the old value last. Withdrawing first turns every holder that has not moved into an immediate failure, which is exactly the outage the exercise is supposed to avoid. The case that inverts the order is a live exposure. If the old value is known to be in someone else's hands, stopping it matters more than the outage that follows, so you withdraw first and accept the breakage. Naming which of the two situations you are in — and therefore which order you chose — is the part interviewers listen for, because a candidate who states one order as universally correct has not thought about the other. ## The trap in one sentence A credential in the store and a credential in a running process are two copies of the same string with no link between them, and every question about "picking up the new value" is really a question about which of those copies you just changed.
- Is "the process restarts to pick up a replacement" an acceptable design?Yes, when it is stated. A replacement then becomes a rolling restart: the old value must stay accepted until the slowest instance has come back, and the cutover window is the time to cycle the fleet. What is not acceptable is assuming a restart will happen without scheduling one, because some instances run for weeks.
- The worker re-resolved the new value but still authenticates with the old one. Where is the bug?In re-application. Re-resolving updated the variable the process holds, while the pool, client objects and retry paths built at start-up still carry the value they were handed, and connections already open were authenticated with it. The reload has to rebuild or re-point those and retire the connections opened earlier.
- Why withdraw the old value last rather than first?Because withdrawing first turns every holder that has not moved into an immediate failure. Replace, move the holders, confirm, then withdraw keeps the cutover invisible. The one situation that inverts the order is a live exposure, where stopping the old value is worth the outage it causes — and you should say which situation you are in.
saying these in an interview costs you the question
- Believes a process sees a new value as soon as the store has it
- Says re-reading the value is enough, without rebuilding the pool
- Confuses replacing a value with withdrawing the old one
- Assumes a restart will happen on its own without scheduling one
- Calls a replacement complete when the store shows the new version
- Withdraws the old value first on a routine replacement