Friday, 1:03 a.m. I'm writing the team a status email, and the second item reads like a confession:
I made a mistake to write a script serially so it's going to take ~8 hours to complete.
The next paragraph is the decision. I'd let it finish, because I wasn't comfortable killing the job halfway through switching datafiles.
I'd pressed Enter at 11:58 p.m. It finished at 5:38 a.m. This note is about why I rode it out, and what I've built into my tools since, so the next person doesn't have to make that call blind at one in the morning.
A standby with no room left
Thursday, August 21, 2014, 5:12 p.m. The standby database, our copy of eHarmony's customer-facing Oracle
database in a second data center, stops applying changes. Recovery dies on
ORA-01237: cannot extend datafile, with ORA-15041: diskgroup space exhausted
underneath it.
The primary is fine, and customers see nothing. But this is the disaster-recovery copy, and every minute it sits still it falls further behind.
We knew the disk group was filling. The plan was to let it fill gradually, then move new files to a disk group on the 1 TB LUNs we'd already presented. Then a migration on the primary created hundreds of new datafiles. Each one was copied to the standby, landed in the old group and started to grow. It filled too soon and too fast.
The fix that didn't fit
Around 9 p.m. the obvious move was to add the new 1 TB disks to the full group and let it rebalance. My work log from that night has the next line verbatim: “MAN this isn't going to work.” Every disk in the old group was 400 GB, and the new ones were 1 TB each, so rebalancing was not going to get me out.
So I flipped it around. Instead of growing the old group, I'd rebuild the new one and move the migration's files into it: 226 datafiles. That frees the old group so its existing files can extend, and gives the new ones somewhere with room to grow.
23 minutes for the heavy part
RMAN moves a datafile in three steps. BACKUP AS COPY writes a copy into the new disk group.
SWITCH DATAFILE … TO COPY tells the database the copy is now the real file.
DELETE DATAFILECOPY removes the original.
The copy is the heavy part, because it reads and writes every byte. I generated that script from the data dictionary with 16 channels, and it copied all 226 files in about 23 minutes:
CONFIGURE DEVICE TYPE DISK PARALLELISM 16;
BACKUP AS COPY
DATAFILE 2655 FORMAT "+NEWDG"
DATAFILE 2656 FORMAT "+NEWDG"
...
DATAFILE 2880 FORMAT "+NEWDG";
All night for the easy part
The switch moves no data. It updates the database's record of where each file lives. I generated it the same way, in a hurry, and it came out as 226 separate commands run one after another:
SWITCH DATAFILE 2655 TO COPY;
SWITCH DATAFILE 2656 TO COPY;
SWITCH DATAFILE 2657 TO COPY;
...
I pressed Enter at 11:58 p.m. and timed the first switch. Multiplied by 226, it came to about eight hours. The step I'd thought of as a formality was now the longest part of the night, and the standby wasn't going to apply anything until it was done.
Ride it or kill it
At 1 a.m. I had two choices. I could kill the job, rewrite the switch to run in parallel and start again, or I could let it run.
Killing it looked like the fast option, and it might have been perfectly safe. Each switch is its own command, and the database records each one as it completes. But I couldn't prove that at 1 a.m., on an Oracle 10g (10.2) standby with half its new files pointing at one disk group and half at the other. If I was wrong, the cost wasn't a slow night. It was rebuilding the disaster-recovery copy of a 22 TB database, and running without one while it rebuilt.
Letting it run had a known cost: lag. The primary was healthy, so waiting cost time, not customers. When stopping safely is a guess and waiting costs only time, you wait.
That's what riding it out means to me, and it isn't stubbornness. By the time a job is running, whether it can be stopped has already been decided by whoever wrote it. That night it was me, and I'd decided it without noticing.
5:38 a.m.
I used the wait. At 1:18 a.m. I asked our storage team for another 1 TB volume, because the migration was still creating files at full speed and the new group would need the room.
The last switch finished at 5:38 a.m.: 5 hours and 40 minutes, about 90 seconds a file. That was faster than my estimate, and it still took most of the night.
The cleanup the next morning made the point for me. Deleting the 226 originals, which I did write with 16 channels, took about three minutes. By 10:17 a.m. recovery was applying again, after falling about 17 hours behind. I also changed where new datafiles get created, so the migration's next files would land in the new group from the start.
The note I left myself
At the bottom of that night's work log, under the scripts that made it happen, I left a warning for whoever did this next:
WARNING -- this was done in serial mode and I should have written it using parallel -- if you do this again make sure to fix it.
Twelve years later, this is what that note turned into. It's four things I build into every tool that changes a fleet.
- Concurrency is a setting, not a rewrite. If one step has a parallelism knob, every step gets one. Running serially should be a choice you make by setting it to 1, never something you did by accident while generating a script in a hurry.
- Stopping is a feature. Work in units, record each unit as it finishes, and make the first Ctrl-C drain: finish the unit in flight, then exit cleanly. Then the 1 a.m. question has an answer: yes, you can stop, and here's where it picks up. Three months later, the match migration's index rebuild ran on workers you could stop and restart at any time.
- Time the first unit and say the total out loud. My eight-hour estimate came from timing a single switch, and it's what let me warn the team at 1 a.m. instead of at breakfast. The tool should print it for you: per-unit time and a projected finish.
- Ask how you'll stop it before you press Enter. Every long step in the run-doc says whether it's safe to kill and how to resume. If the honest answer is “don't”, you budget the night and tell people before you start.
It's the shape hammerdown is built on: a --workers count you set
for each run, one lock per shard, and a first Ctrl-C that drains: in-flight work finishes and nothing new
starts.
Before you press Enter
Nobody noticed that night. The primary never blinked, the standby caught up, and the only cost was my sleep. That was the right trade, but I'd only had to make it because of a script I wrote in a hurry.
Know how you'll stop it before you start it. If you can't, budget the night, and say so before you press Enter.
HASHJOIN Field Notes
New tools and field notes on running production fleets: rolling upgrades, incident forensics, and Claude-augmented ops. About once a month, no spam.
Running long, risky changes across a fleet by hand?
HASHJOIN builds the tooling that makes them stoppable, resumable and boring: a worker count you set per run, a lock per unit, a drain on the first Ctrl-C, and a projected finish you can tell people about. Fixed scope, and you own all of the code.
