All jobs / Database administrator / Automation
Database administrator interview question · 3–5 years
What does it take to make a maintenance script safe to run twice, and why insist on it?
The strongest answer
It checks state before acting, so a second run changes nothing new — create if missing, skip completed work, record progress durably — because scripts do get re-run after a timeout or failover
Why it works
Exactly — idempotence is what lets you retry without thinking, which is the whole point at three in the morning.
What a good answer covers
- Check state before acting.
- A second run changes nothing.
- Record progress durably.
- Assume retries will happen.
Answers that fall short
- Close, but not the strongest: It should not fail when the object already exists, so I put a check in front of every step
That is most of it; the harder half is work that partly completed, which needs recorded progress rather than an existence check. - Weak: I would make it safe by running it only once and keeping a note that it has been run
A note is not a control — reruns come from automation, retries and failovers, not from someone forgetting. - Red flag: Running it twice is operator error; the script should not have to defend itself against that
Blaming the operator for a retry the system itself made is how a one-off script becomes an incident.
Who gets asked this
More Automation questions
- How do your maintenance and backup jobs authenticate to the databases, without a password sitting in a script?
- Two hundred database servers need the same configuration change, and you are writing a PowerShell script to…
- You inherit a fleet where each DBA keeps their own scripts on their own jump box, and the checks differ from…
- You are writing a small shell script that takes a backup on a Linux database server. What must it do besides…
- What do you put into a SQL script before it is allowed to run against production?
- The nightly maintenance job has not run for three weeks. Nobody noticed, because the dashboard only shows…