News for hackers. Stuff that matters.
Re:GitLab Database Incident – Live Report by ams6110 on Tuesday January 31, 2017 @08:02PM (#13537128)
23:00-ish

YP thinks that perhaps pg_basebackup is being super pedantic about there being an empty data directory, decides to remove the directory. After a second or two he notices he ran it on db1.cluster.gitlab.com, instead of db2.cluster.gitlab.com

Good lesson on the risks of working on a live production system late at night when you're tired and/or frustrated.

Re:GitLab Database Incident – Live Report by theptip on Tuesday January 31, 2017 @08:08PM (#13537169)
Also, as a safety net, sometimes you don't need to run `rm -rf` (a command which should always be prefaced with 5 minutes of contemplation on a production system). In this case, `rmdir` would have been much safer, as it errors on non-empty directories.
Re:GitLab Database Incident – Live Report by piinbinary on Tuesday January 31, 2017 @08:18PM (#13537254)
Or use `mv x x.bak` when `rmdir` fails
Re:GitLab Database Incident – Live Report by shawn-furyan on Tuesday January 31, 2017 @09:35PM (#13537675)
Or even instead of any kind of rm command. mv is less subtle. I tend to prefer

    `mv x $(date +%Y%m%d_%s_)x`
where:

    %Y - 4 digit year
    %m - 2 digit month
    %d - 2 digit day
    _  - underscore literal
    %s - linux timestamp (seconds since epoch)
This ensures that the versions you're 'removing' will be lexically sorted from newest to oldest in a way that is easy to interpret and also works if you need to try more than once in a day.

In case it's not apparent to some, this command moves the directory (or file) called

    'x'
to something like

    '20170131_1485916040_x'
Then when you're all done (i.e. production is humming and passing tests, no need to ever rush), you can delete the timestamped version, or if space is plentiful, move the old file to an archive directory as an extra redundancy (i.e. as an extra backup, not in lieu of a more thorough backup policy).
Re:GitLab Database Incident – Live Report by krenoten on Tuesday January 31, 2017 @09:43PM (#13537728)
This needs to be the first thing anyone who works with stateful systems learns. NEVER rm. mv is insufficient. mv dir dir.bak.`date +%s` has prevented data loss for me several times.
Re:GitLab Database Incident – Live Report by bpchaps on Tuesday January 31, 2017 @10:48PM (#13538052)
I agree with what you're saying, and this is almost exactly what I do, but when disk space is limited - particularly during time-sensitive situations - this advice isn't very useful. For example, if a host or service is on the cusp of crashing because of a partition quickly filling up with rolling logs, what do you do since mv doesn't actually solve the problem?

At some level you have to run an rm, and you better hope you do it right in the middle of an emergency with people breathing over your shoulder.

In an ideal world, this wouldn't ever happen, but it does. Inherited/legacy systems suck.

Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 01, 2017 @12:13AM (#13538453)
You shouldn't let yourself get to that point. Your alerting system should alert you when disk is at 70% or something with a ton of margin. If it's not set up that way, go stop what you're doing and fix that. (Seriously.) If you're running your systems so they usually run at 90% disk usage, go give them more disk (or rotate logs sooner).

And even assuming all that fails and I'm in that situation where I have seconds until the disk hits 100%, I would much rather the service crashes than make a mistake and delete something critical.

If someone is breathing over your shoulder, you can even enlist them to co-pilot what you're doing. Even if they're not technical enough to understand, talking at them what you're about to do will help you spot mistakes.

Re:GitLab Database Incident – Live Report by bpchaps on Wednesday February 01, 2017 @01:42AM (#13538845)
If you lose a shoe while running across a highway, it's probably not worth the risk trying to get it back.

The disk usage is just one example of many. Actions that you take really depends on what field you're in and, and again, legacy/inherited systems are completely filled with this sort of shit.. You can say that I shouldn't let get it to that point, but you're kinda dismissing the point I'm trying to make that - shit can and will happen, and you need to know how to deal with shit on your toes. There are times when you have to do things that would make most people flip there shit. There are ways to mitigate the risk in emergency scenarios as you say, but when the risk is actually worth it, you tend to do Bad Things because there's no other option.

In my case, it was in HFT where I inherited the infrastructure from a JS developer who inherited it from a devops engineer who inherited it from a linux engineer who inherited it from another linux engineer. It was a complete shitshow that I was dropped into mostly on my own with little warning. To make matters worse, each maintenance period was 45 minutes at 4:15pm and weekends. Even worse, if a server went down at 5:00pm, the company immediately lost about 35k - which was the same for if the trading software went down. When I asked for additional hardware to do testing on, I was told that there wasn't a budget for it. The saving grace there was that there was 23:15h of time to plan during downtime, so an `rm -rf /` would have had nearly identical long term impact as a `kill -9` on the application server.

Mind you, the owners of the company were some of the smartest and most technical folk I've ever worked with and were surprisingly trusting in my ability to manage the infrastructure. The company no longer exists, and not without reason.

Just to show the lunacy of the infrastructure - they had their DNS servers hosted on VMs that required DNS to start. About a month after I joined, we had a power failure. You can imagine how that went..

(That all said, it was the greatest learning experience I've ever had. Burned me out a tad, though.)

Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 15, 2017 @01:28AM (#13650150)
I don't mean to sound flippant, but if I walked into the situation you describe, I would immediately walk right back out. That is a a situation set up from the start for failure, and no way would I care to be responsible for it.

I certainly get that we inherit less-than-ideal systems from time to time; I've been there. But I've also learned that every time I get paged in the middle of the night, it's my failure, whether for a lack of an early-warning system, or for doing a bad up-front job of building self-healing into my systems. If I inherit a system that I can tell is going to wake me up at night, I refuse to be responsible for it in an on-call capacity until I've mitigated those problems.

There seems to be this weird thing in the dev/ops world where it's somehow courageous to be woken up at 3am to heroically fix the system and save the company. I've been that guy, and I'm sick of it. It's not heroic: it's a sign of a lack of professionalism leading up to that point. Make your systems more reliable, and make them continue to chug along in the face of failure, without human interaction. If you have management that doesn't support that approach, make them support it, or walk out. Developers and operations people are in high enough demand right now in most markets that there will be another company that would love to have you, hopefully with more respect for your off-duty time.

Re:GitLab Database Incident – Live Report by macintux on Wednesday February 01, 2017 @01:28PM (#13543422)
I once tried to help a company with similar infrastructure insanity recover from a massive failure. Absolutely brutal.

When my team finally got services up and running (barely) after ~18 hours of non-stop work, the CTO demanded that we not go home and get some sleep until everything was exactly as it had been before the failure.

Not my happiest day.

Re:GitLab Database Incident – Live Report by danielsamuels on Wednesday February 01, 2017 @02:26AM (#13539022)
> You shouldn't let yourself get to that point. Your alerting system should alert you when disk is at 70% or something with a ton of margin.

What would your recommendation be?

Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 15, 2017 @01:38AM (#13650181)
Unfortunately the answer is "it depends on the application". I tend to run stuff with even higher margins: I never expect more than 30-40% disk utilization. Yes, it's more expensive, but I value my (and my colleagues') sleep more.

But it's all just about measurement. Run your application with a production workload and see how large the logs are that it generates within defined time intervals. Either add disk or reduce logging volume until you're happy with your margins. (Logging is often overlooked as something you need to design, just like you design the rest of your application.)

Log rotation should be a combination of size- and time-based. You probably want to only keep X days of logs in general, but also put a cap on size. If you're on the JVM, logback, for example, lets you do this: if you tell it "keep the last 14 log files and cap each log file at 250MB", then you know what the max disk usage for logging will be.

If you can do it, use an asynchronous logging library that can fail without causing the application to fail. If your app is all CPU and network I/O, there's no reason why it needs disk space to function properly. If you can afford it, use some form of log aggregation that ships logs off-host. Yes, you've in some ways just moved the problem elsewhere, but it's easier to solve that once in one service (your log aggregation system) than in every individual service.

If your app does require disk space to function properly, then of course it's a bit harder, and protecting against disk-full failures will require you to have intimate knowledge of what it needs disk for, and what the write patterns are.

It's never going to be perfect. Just a 100% uptime is, over a longer time scale, unachievable, you're never going to eliminate every single thing that can get you paged in the middle of the night. But if you can reduce it to that one-in-a-million event, your time on-call can really be peaceful. And when you do get that page, look really hard at why you got paged, and see what you can do to ensure that particular thing doesn't require human intervention to fix in the future. You may decide to cost of doing so isn't worth the time, and that getting woken up once every X days/weeks/months/whatever is fine. But make that your choice; don't leave it up to chance.

Re:GitLab Database Incident – Live Report by bpchaps on Wednesday February 01, 2017 @04:12AM (#13539440)
I'm curious, too. Proper disk space management and monitoring is probably the most difficult problem I know of in the ops field. I haven't seen anybody do it in a way that prevents 3am wakeup calls or a 24/7 ops team.

For example, a 3am network blip that causes the application server (still logging in DEBUG from the last outage) to fill up its log partition while it can't communicate to some service nobody monitors anymore. Not sure how you'd solve that one.

Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 15, 2017 @01:48AM (#13650217)
> For example, a 3am network blip that causes the application server (still logging in DEBUG from the last outage)

Nope. Don't do that. Infra should be immutable. If you need to bring up a debug instance to gather data, that's fine, but shut it down when you're done. If you don't, and it causes an issue, you know who to blame for that.

> to fill up its log partition while it can't communicate to some service nobody monitors anymore.

Sane log rotation policies (both time- and size-based) solves this. If you tell your logging system "keep 14 old log files and never let any single log file to grow above 250MB", then you know the upper bound on the space your application will ever use to log.

Also, why are you not monitoring logs on this service. If it's spewing "ERROR Can't talk to service foo" into its log file, why aren't you being alerted on that well before the disk fills up?

> ... nobody monitors anymore.

Nope. Not allowed. Fix that problem too. Unmonitored services aren't allowed in the production environment, ever.

I've heard (and given) all the excuses for this, but no, stop that. You're a professional. Do things professionally. When management tells you to skimp on monitoring and failure handling in order to meet a ship date, you push back. If they override you, you refuse on-call duty for that service. (Or you just ignore their override and do your job properly anyway.) If they threaten to fire you, you quit and find a company that has respect for your off-duty time. Good devs & ops people are in high enough demand these days that you shouldn't be unemployed for long.

Re:GitLab Database Incident – Live Report by foxylion on Wednesday February 01, 2017 @01:58PM (#13543739)
We just switched over to centralized logging two years ago. All hosts are configured to only keep small logfiles and rolling them over every few megabytes. Filling up the centralized logging is nearly impossible when good monitoring is done and used diskspace is never over 50%.

Btw. using an orchestration platform simplifies many of those aspects of "one node is going rough and I've to do accidentally something stupid".

Re:GitLab Database Incident – Live Report by devdas on Wednesday February 01, 2017 @06:58AM (#13540010)
Monitor the rate at which the disk is filling up, and extrapolate that to when it will hit 90%. If that time is outside business hours, alert early. If current time is not in business hours, alert later if possible.
Re:GitLab Database Incident – Live Report by bpchaps on Wednesday February 01, 2017 @12:25PM (#13542713)
How does this help in situations where something rogue starts filling the disk? The idea makes sense in theory, but in practice, it doesn't work out that well. Ops work is significantly harder than many devs think..
Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 15, 2017 @01:50AM (#13650227)
> Ops work is significantly harder than many devs think

No, it's not (I've done both). Ops is about process, and risk analysis and mitigation. Yes, there's always the possibility that something can go rogue and start filling your disk. That shouldn't be remotely common, though, if you've built your systems properly.

Re:GitLab Database Incident – Live Report by 1zq on Wednesday February 01, 2017 @05:09AM (#13539610)
To this I would add: always pass "-i" to any interactive use of mv. This has also helped me prevent data loss a few times.
Re:GitLab Database Incident – Live Report by hobarrera on Tuesday January 31, 2017 @09:53PM (#13537781)
date -Im is shorter and easier to remember (though not 100% standard, IIRC). ;)

Example: 2006-08-14T02:34:56-06:00

Re:GitLab Database Incident – Live Report by traviscj on Wednesday February 01, 2017 @09:08AM (#13540765)
You can "brew install coreutils" and then use "gdate " on macOS.
Re:GitLab Database Incident – Live Report by bpchaps on Tuesday January 31, 2017 @08:15PM (#13537233)
These days, I've been very implicit in how I run rm. To the extent that I don't do rm -rf or rmdir (edit: immediately), but in separate lines as something like:

  pushd dir ; find . -type f -ls | less ; find . -type f -exec rm '{}' \; ; popd ; rm -rf dir
It takes a lot longer to do, but I've seen and made enough mistakes over the years that the forced extra time spent feels necessary. It's worked pretty well so far -- knock knock.
Re:GitLab Database Incident – Live Report by kstrauser on Tuesday January 31, 2017 @10:05PM (#13537843)
BTW,

  find ... -delete
avoids any potential shell escaping weirdness and saves you a fork() per file.
Re:GitLab Database Incident – Live Report by wodny on Wednesday February 01, 2017 @08:50AM (#13540653)
This seems to be the best here. As a side note: if someone does something more complicated and uses piping find output to xargs, there are very important arguments to find and xargs to delimit names with binary zero -- -print0 and -0 respectively.

Very interesting article: https://www.dwheeler.com/essays/fixing-unix-linux-filenames.....

Re:GitLab Database Incident – Live Report by willemmali on Wednesday February 01, 2017 @03:33PM (#13544821)
I've been writing an `sh`-based tool to check up on my local Git repos, and it uses \0-delimited paths and a lot of `find -print0` + `xargs -0`:

https://gitlab.com/willemmali-sh/chegit/blob/master/chegit#L...

I admit the code can look a little weird, but it was because I had some rather tight contrainst: 1 file, all filenames `\0` separated internally and just POSIX `sh`. I still wanted to reuse code and properly quote variables inside `xargs` invocations (because `sh` does not support `\0`-separated read's), so I ended up having to basically paste function definitions into strings and use some fairly expansive quotation sequences.

Re:GitLab Database Incident – Live Report by bpchaps on Wednesday February 01, 2017 @10:15PM (#13547799)
Nice plug for gitlab ;).

\0 is an insanely useful separator for this sort of thing and yeah, it definitely gets messy. I'm working on a similar project that uses clojure/chef to read proc files in a way that causes as little overhead as possible. \0 makes life so much easier used. The best example I can think of off of the top of my head is something similar to:

  bash -c "export FOO=1 ; export BAR=2 && cat /proc/self/environ | tr '\0' '\n' | egrep 'FOO|BAR'"
  FOO=1
  BAR=2
Re:GitLab Database Incident – Live Report by willemmali on Thursday February 02, 2017 @10:18AM (#13551060)
I was so freaked out at the news, I normally have local backups of my projects but I just happened to be in the middle of a migration where my code was just on Gitlab, and then they went down... Luckily it all turned out OK.

\0 is very useful but I really wish for an updated POSIX sh standard with first-class \0 support.

On your code, why do you replace \0's with newlines? egrep has the -z flag which makes it accept \0-separated input. A potential downside to it is that it automatically also enables the -Z flag (output with \0 separator).

I solved the "caller might use messy newline-separated data"-problem by having an off-by-default flag that makes all input and output \0-separated; this is handled with a function called 'arguments_or_stdin' (which does conversion to the internal \0-separated streams) and 'output_list' (which outputs a list either \0- or \n-separated depending on the flag).

Re:GitLab Database Incident – Live Report by gizmo on Tuesday January 31, 2017 @08:43PM (#13537408)
Good advice.

I would add a step where you dump the output of find (after filtering) into a textfile, so you have a record of exactly what you deleted. Especially when deleting files recursively based on a regular expression that extra step is very worthwhile.

It's also a good practice to rename instead of delete whenever possible. Rename first, and the next day when you're fresh walk through the list of files you've renamed and only then nuke them for good.

Re:GitLab Database Incident – Live Report by foobiekr on Tuesday January 31, 2017 @10:46PM (#13538050)
I am actually curious what user they were logged in as and what permissions were in effect.

Unfortunately, the answer most places is that the diagnostic account (as opposed to the corrective action account) is fully privileged (or worse, root).

Re:GitLab Database Incident – Live Report by kelnos on Wednesday February 01, 2017 @12:15AM (#13538468)
From a comment in the doc ("YP says it’s best for him not to run anything with sudo any more today, handing off the restoring to JN"), I assume they're running as a regular user, sudo'ing as necessary.
Re:GitLab Database Incident – Live Report by YorickPeterse on Wednesday February 01, 2017 @06:34AM (#13539898)
A regular user that can use `sudo`.
Re:GitLab Database Incident – Live Report by weavie on Wednesday February 01, 2017 @06:52AM (#13539972)
Alternatively, if you have the luxury - `zfs snapshot`.
Re:GitLab Database Incident – Live Report by chousuke on Wednesday February 01, 2017 @02:06PM (#13543828)
Having a snapshotting storage system (NetApp) once saved a lot of pain when I accidentally deleted the wrong virtual machine disk from an internal server (hit the system disk instead of a removed data disk) I was able to recover the root disk from a snapshot and bring up the machine in less than an hour.

Snapshots are not a backup strategy, but they make me sleep better at night regardless.

Re:GitLab Database Incident – Live Report by Bad_CRC on Wednesday February 01, 2017 @11:30AM (#13542084)
lsof -> check if a process is accessing that file/directory.
Re:GitLab Database Incident – Live Report by eric_h on Tuesday January 31, 2017 @08:05PM (#13537149)
Good lesson on making command prompts on machines always tell you exactly what machine you're working on.
Re:GitLab Database Incident – Live Report by m_fam_wa_k on Tuesday January 31, 2017 @08:09PM (#13537184)
I like to color code my terminal. Production systems are always red. Dev are blue/green. Staging is yellow.
Re:GitLab Database Incident – Live Report by Perihelion on Tuesday January 31, 2017 @08:15PM (#13537232)
All of my non-production machines have emojis in PS1 somewhere. It sounds ridiculous, but I know that if I see a cheeseburger or a burrito I'm not about to completely mess everything up. Silly terminal = silly data that I can obliterate.
Re:GitLab Database Incident – Live Report by StavrosK on Tuesday January 31, 2017 @09:19PM (#13537611)
I think I'd rather make the production systems stand out, and add the emojis there. My prompts have a red background, but emoji prompts just tickle me, somehow.
Re:GitLab Database Incident – Live Report by kofejnik on Tuesday January 31, 2017 @08:24PM (#13537294)
I've been color-coding my PS1 for years, but this is seriously brilliant, thanks!
Re:GitLab Database Incident – Live Report by marcosdumay on Wednesday February 01, 2017 @08:26AM (#13540515)
I got the idea of an emoji prompty that is happy or sad depending on the $? value from somebody here a few years ago.

I run it on any dev environment since then.

Re:GitLab Database Incident – Live Report by scrame on Tuesday January 31, 2017 @11:41PM (#13538306)
ha! I do the same thing with figlet and cowsay, it prints a big dragon saying "welcome to shell!", if I see that, then I know I'm on a box I own/have sudo/am me. it's a good visual reminder. I don't fuss with prompts much, but this is a pretty good idea!
Re:GitLab Database Incident – Live Report by kevindong on Tuesday January 31, 2017 @08:53PM (#13537471)
It seems Gitlab has noticed your comment.

Recovery item 3f currently says:

> Create issue to change terminal PS1 format/colours to make it clear whether you’re using production or staging (red production, yellow staging)

Re:GitLab Database Incident – Live Report by gknoy on Tuesday January 31, 2017 @08:18PM (#13537252)
I use iterm2's "badging" to set a large text badge on the terminal of the name of the system as part of my SSH-into-ec2-systems alias:

    i2-badge ()
    {
      printf "\e]1337;SetBadgeFormat=%s\a" $(echo -n "$1" | base64)
    }
It's not quite as good as having a separate terminal theme, but then I haven't been able to use that feature properly. :(
Re:GitLab Database Incident – Live Report by amatix on Wednesday February 01, 2017 @05:20AM (#13539639)
This is a great idea! Documentation https://www.iterm2.com/documentation-badges.html -- supports emojis too fwiw
Re:GitLab Database Incident – Live Report by ubercow on Tuesday January 31, 2017 @11:48PM (#13538335)
Didn't know about this feature, gonna have to use this thanks!
Re:GitLab Database Incident – Live Report by TimWolla on Tuesday January 31, 2017 @08:13PM (#13537215)
In this case it looks like it has been a confusion between two different replicated Production databases. So this would not have helped.
Re:GitLab Database Incident – Live Report by sytse on Tuesday January 31, 2017 @08:15PM (#13537225)
Yep, good idea. The same thing has been suggested by team members http://imgur.com/a/TPt7O
Re:GitLab Database Incident – Live Report by niftich on Tuesday January 31, 2017 @08:14PM (#13537220)
I do this too, but in this case both machines were production, so this alone would not have sufficed. The system-default prompts on the other hand are universally garbage.
Re:GitLab Database Incident – Live Report by NamTaf on Wednesday February 01, 2017 @02:10AM (#13538961)
I have a user and a local admin account at work on our Windows SOE. I have made my PC's cmd.exe show green on black in large font, but intentionally did not change the local admin. When I run a command prompt in admin it's visible different. This is a great tip and it's caught me many times.
Re:GitLab Database Incident – Live Report by nodesocket on Wednesday February 01, 2017 @03:38AM (#13539307)
If using iterm you can set a "badge" text on a terminal window that shows up as an overlay. Super useful when you have lots of SSH sessions open to different servers.
Re:GitLab Database Incident – Live Report by corecoder on Wednesday February 01, 2017 @06:15AM (#13539828)
iterm badges have saved me many times.
Re:GitLab Database Incident – Live Report by cabargas on Tuesday January 31, 2017 @08:16PM (#13537238)
Is a really good idea, and is one of the improvements that are likely to be put in place as soon as possible. Its already listed on the document.
Re:GitLab Database Incident – Live Report by karmicthreat on Tuesday January 31, 2017 @09:09PM (#13537552)
I've done this exact thing my my servers. Also like GL I prepend PRODUCTION and STAGING on PS1.

I should probably make the PRODUCTION flash just in case.

Re:GitLab Database Incident – Live Report by hobarrera on Tuesday January 31, 2017 @10:01PM (#13537823)
We need a <blink> tag for our PS1.
Re:GitLab Database Incident – Live Report by spydum on Tuesday January 31, 2017 @10:17PM (#13537903)
Good news! Enable ANSI in your terminal and: ESC[5m

http://wiki.bash-hackers.org/scripting/terminalcodes

Re:GitLab Database Incident – Live Report by eric_h on Friday February 03, 2017 @08:28AM (#13559631)
You can do that - I actually tried it and everyone on my team agreed that it was bloody annoying, so I made it stop blinking (still red, though).
Re:GitLab Database Incident – Live Report by Ezhik on Tuesday January 31, 2017 @10:57PM (#13538101)
Not as serious, but I always set root terminals on my system to be this scary red.
Re:GitLab Database Incident – Live Report by joshaidan on Tuesday January 31, 2017 @08:13PM (#13537213)
How do you go about colour coding your terminal?
Re:GitLab Database Incident – Live Report by TimWolla on Tuesday January 31, 2017 @08:16PM (#13537234)
I assume he color coded the prompt. You can use ANSI color escape codes in there to e.g. color your hostname.

Here's a generator for Bash: http://bashrcgenerator.com/, the prompt's format string is stored in the $PS1 variable.

Re:GitLab Database Incident – Live Report by simooooo on Wednesday February 01, 2017 @02:43AM (#13539095)
My dev is yellow, staging orange, and live red
Re:GitLab Database Incident – Live Report by tokenizerrr on Tuesday January 31, 2017 @08:14PM (#13537221)
How exactly do you color code it?
Re:GitLab Database Incident – Live Report by x0x0 on Wednesday February 01, 2017 @02:31AM (#13539043)
for example, in .bashrc on osx:

   RED=$(tput setaf 1)
   NORMAL=$(tput sgr0)
   PS1="\[${RED}\]PROD \[${NORMAL}\]\W\$ "
produces prompt

PROD ~$ <-- prod in red, directory ~

Re:GitLab Database Incident – Live Report by wtbob on Tuesday January 31, 2017 @10:30PM (#13537971)
'db1' vs. 'db2' is still insufficiently clear, though. Even better would be e.g. to name development systems after planets and production systems after superheroes. Very few people would mistake 'superman' for either 'green-lantern' or 'pluto,' but it's really easy to mistake 'sfnypudb13' for 'sfnydudb13.'
Re:GitLab Database Incident – Live Report by grzm on Tuesday January 31, 2017 @10:53PM (#13538079)
Or skip the middleman: prod-db1, prod-db2, dev-db1, dev-db2.
Re:GitLab Database Incident – Live Report by wtbob on Tuesday January 31, 2017 @11:04PM (#13538139)
Visually there's not a whole lot of difference. Ideally, you want something where the shape of each name is reasonably distinct from all the rest — otherwise folks will just ignore that odd blot before the prompt.

And then, once you've started naming things as $ENV-$TYPE, someone will want to cram in the location, and the OS, and the team which maintains it, and the customer, and and and. Then someone will reduce all of those identifiers into single characters … and you'll be in the situation I mentioned. Clearly clpudb1 is CharlesCorp's first London production database system!

Re:GitLab Database Incident – Live Report by grzm on Tuesday January 31, 2017 @11:26PM (#13538227)
I strongly argue against those types of abbreviations in naming, for exactly the points you make.

Here's how I view it:

The distinction between prod and dev is pretty clear cut. The words "dev" and "prod" have significantly different shapes and are immediately unambiguous. There's no need to remember a superhero vs astronomical object distinction.

As the number of database server instances grows, you've got another level of naming issues that arises when needing to distinguish between hosts and db server instances—and perhaps even database/schema independence if necessary. Staying consistent and easy-to-use with an arbitrary naming scheme becomes increasingly unwieldy, in my opinion.

Re:GitLab Database Incident – Live Report by sratner on Wednesday February 01, 2017 @06:48AM (#13539946)
Additionally, I have taken up a habit of not abbreviating "production" and "staging", whenever possible. The fact that len("production") > len("staging") > len("dev") is a feature when you find yourself typing it into a terminal or db shell.
Re:GitLab Database Incident – Live Report by traviscj on Wednesday February 01, 2017 @09:17AM (#13540839)
At work we have an ascii-art, most-of-80x40-filling version of our logo rendered in an environment-associated color on login + matching prompt. The ascii-art logo might not have helped in this case (if it was a long sequence of console interactions), but It does catch "db1" vs "db2" typos, for instance, and also elicits a certain reverence upon connection.
Re:GitLab Database Incident – Live Report by echelon on Tuesday January 31, 2017 @08:17PM (#13537250)
This doesn't really help if there are multiple production databases. It could be sharded, replicated, multi-tenant, etc.
Re:GitLab Database Incident – Live Report by gnufied on Tuesday January 31, 2017 @08:21PM (#13537280)
Why would it matter? In my last job we had user home directories synced via puppet (I am overly simplifying this) which enabled any ops guy to have same set of shell and vim configuration settings on production machines too.

I daresay - having hostname as part of prompt saves lot of trouble.

Re:GitLab Database Incident – Live Report by echelon on Wednesday February 01, 2017 @03:27AM (#13539267)
Having the hostname on the prompt is a good idea, but I don't think it would have helped with this process failure.

I work at a company where we have hundreds of database machines. Running this kind of command _anywhere_ without some kind of plan would be foolish. (It's one of the reasons why we have a datastore team that handles database administration.)

But the same lesson applies to application servers as well. Don't run deleterious commands out of curiosity. Have a peer-reviewed roll plan to act on when doing things like this. A role plan would have called for verifying the host before running the command.

But even before that, the issue should have been investigated more!

All of these things contributed to the failure. There should ideally be better ownership through dedicated roles, peer-reviewed processes for dangerous activities, and a better process for investigation that does not involve deleting things haphazardly.

Re:GitLab Database Incident – Live Report by dorfsmay on Tuesday January 31, 2017 @08:36PM (#13537357)
Uh no! Don't rely on command prompt, there are hardcoded ones out there, and clonining scripts have duplicated them.

uname -n

Takes seconds.

Re:GitLab Database Incident – Live Report by vacri on Tuesday January 31, 2017 @08:45PM (#13537422)
colour is more noticeable than words. I do both, though.
Re:GitLab Database Incident – Live Report by sbuttgereit on Tuesday January 31, 2017 @08:12PM (#13537202)
Also a good lesson for testing your availability and disaster recovery measures for effectiveness.

Far, far too many companies get production going and then just check to see that certain things "completed successfully" or didn't throw an overt alert in terms of their safety nets.

Just because things seem to be working doesn't mean they are or that they are working in a way that is recoverable.

Re:GitLab Database Incident – Live Report by craigkerstiens on Tuesday January 31, 2017 @10:42PM (#13538034)
I'm not sure there is a "late" at night or tired in the incident report. All times are UTC and it's unclear where all the team is located but if in SF then this is at 4pm which is when the incident just occurred. It doesn't necessarily change that you shouldn't be firefighting for extremely long cycles in hero-mode for that long, but not exactly the same as exhausted and powering away for hours.
Re:GitLab Database Incident – Live Report by Scriptor on Tuesday January 31, 2017 @11:30PM (#13538250)
Gitlab's team is worldwide. YP seems to be someone in EU time, which right now is UTC+1.

That would mean that the incident happened around 11pm or midnight in YP's local time.

Re:GitLab Database Incident – Live Report by YorickPeterse on Wednesday February 01, 2017 @05:01AM (#13539578)
Correct, I'm based in Europe/Amsterdam so this happened mostly during the evening.
Re:GitLab Database Incident – Live Report by sbuttgereit on Tuesday January 31, 2017 @11:29PM (#13538247)
Actually, there is a brief comment:

"At this point frustration begins to kick in. Earlier this night YP explicitly mentioned he was going to sign off as it was getting late (23:00 or so local time), but didn’t due to the replication problems popping up all of a sudden."

Re:GitLab Database Incident – Live Report by anamoulous on Tuesday January 31, 2017 @10:33PM (#13537993)
I audibly gasped when I hit this part of the document.
Re:GitLab Database Incident – Live Report by 1_2__3 on Tuesday January 31, 2017 @11:56PM (#13538377)
I think I can count on one hand the number of times I've run an rm command on a production server. I'll move it at worst, and only delete anything if I'm critically low on disk space. But even then I don't even like typing those characters if I can avoid it, regardless of if I'm running as root or a normal user.
Re:GitLab Database Incident – Live Report by cesarb on Tuesday January 31, 2017 @08:56PM (#13537485)
> Good lesson on the risks of working on a live production system late at night when you're tired and/or frustrated.

In these situations, I always keep the following xkcd in mind: https://xkcd.com/349/

Re:GitLab Database Incident – Live Report by mbrain on Wednesday February 01, 2017 @05:17AM (#13539630)
Just a thought, but is it possible to override destructive commands to confirm the hostname by typing it before running the command?