Live data from Hacker News

Postmortem of database outage of January 31

about.gitlab.com

181–190 of 269 posts

Re: Postmortem of database outage of January 31

#181
post #179

Watching GitLab is somewhat painful. I feel like they make every possible mistake you could do as an IT startup and because they are transparent about it people seem to love the fact that they screw up all the time. I don't know if I share the same mentality, because at the end of the day I don't trust GitLab even with the simplest task, let alone any valuable work of mine. It's good to be humble and know that mistak…

I had exactly the same feeling. One of my friends was a doctor at a hospital and there was a serious mistake which my friend reported to the consultant. The consultant made a good point that it was never just one mistake that caused the serious mistake; it was a series of smaller mistakes that hadn't been checked or addressed. (the argument was that there were processes to avoid these kinds of mistakes) If you read t…

[deleted]

Re: Postmortem of database outage of January 31

#182
>Unfortunately DMARC was not enabled for the cronjob emails, resulting in them being rejected by the receiver. This means we were never aware of the backups failing, until it was too late.

At my dayjob, we gradually stopped using email for almost all alerts, instead we have several Slack channels like #database-log where errors to MySQL go. Any cron jobs that fail post in #general-log. Uptime monitoring tools post in #status. So on...

Email has so much anti-spam stuff like DMARC that make it less reliable your mail will be delivered. For something failing like a backup or database query, it's too important to have potentially not reach someone who can make sure it gets fixed.

My 2 cents.

Re: Postmortem of database outage of January 31

#183
This is an outstanding writeup, but I wonder if it glosses over the real problem:

>>The standby (secondary) is only used for failover purposes.

>>One of the engineers went to the secondary and wiped the data directory, then ran pg_basebackup.

IMO, secondaries should be treated exactly as their primaries. No operation should be done on a secondary unless you'd be OK doing that same operation on the primary. You can always create another instance for these operations.

Re: Postmortem of database outage of January 31

#184

Earlier quoted context omitted.

Still here, and doing just fine.

I love your tag line here on HN! Some 15 yrs ago I was hired as a UNIX administrator at some larger company. Despite being fresh from school I already had plenty of experience from spending the 90's hacking and programming on whatever UNIX system fyodor or rootshell.com had an exploit for. When the DBA was leaving for vaccation they didn't hesitate in letting me take over his daily routines. On this particular summer…

>Personally I'd rather hire someone who was a "removal" specialist over someone who hadn't learned the skill yet.

Oh absolutely. Problem is that gitlab didn't do that. And they will most likely have to learn many more lessons before become reliable.

Re: Postmortem of database outage of January 31

#185
post #31

Earlier quoted context omitted.

People get tired, sick, frustrated, panic - part of being a responsible engineer is accepting you're as fallible as the next person and building in protection against your own errors. However, if "the engineer" that caused this happens to read this, the above is not a sign that you should quit the profession and become a hermit. A chain of events caused this, you just happened to be the one without a chair to sit in…

One of the coolest things I've read about is how airlines do root cause analysis. If you get to a point where a human can mess up the situation like this, it's considered a systemic issue. Mobile now, but can try to find it later EDIT: https://dvikan.no/ntnu-studentserver/reports/A%20Human%20Err... > That is, much like falling dominoes, Bird and others (Adams, 1976; Weaver, 1971) have described the cascading nature o…

In general, in aviation, the existence of any single point of failure (SPOF) is considered a systemic issue, be it a single human who can fail (anyone can faint or have a heart attack), a single component, or a single process. That's why there are not only redundant systems, but redundant humans and even redundant processes for the same task (you can power the control surfaces hydraulics through the engines, then through the aux power unit, then through the windmill... ).

If a design contains an SPOF, then it's a bad design and should not be approved until the SPOF is removed by adequate redundancy or other means.

Re: Postmortem of database outage of January 31

#186

I really hate to pile on, but after reading through this whole thread and the whole post-mortem, there are a few basic things that are troubling besides the widely-acknowledged backup methodology. I don't see issues directly related to addressing these things. 1. notifications go through regular email. Email should be only one channel used to dispatch notifications of infrastructure events. Tools like VictorOps or Pa…

    > 1. notifications go through regular email. Email should be only one
    > channel used to dispatch notifications of infrastructure events. Tools
    > like VictorOps or PagerDuty should be employed as notification
    > brokers/coordinators and notifications should go to email, team chat, and
    > phone/SMS if severity warrants, and have an attached escalation policy so
    > that it doesn't all hinge on one guy's phone not being dead.
This is discussed in https://gitlab.com/gitlab-com/infrastructure/issues/1095. We're basically looking into moving to Prometheus monitoring combined with Pagerduty notifications.

    > 2. there was a single database, whose performance problems had impacted
    > production multiple times before (the post lists 4 incidents). One such
    > performance problem was contributing to breakage at this very moment. I
    > understand that was the thing that was trying to be fixed here, but what
    > process allowed this to cause 4 outages over the preceding year without
    > moving to the top of the list of things to address?
High availability has been a thing we wanted to do for a while, but for whatever reason we just never got to it (until recently). Not sure exactly why.

    > Wouldn't it be wise to tweak the PgSQL configuration and/or upgrade the
    > server before trying to integrate the hot standby to serve some read-only
    > queries?
The server itself is already quite powerful, and the settings should be fairly decent (e.g. we used pgtune, and spent quite a bit of time tweaking things). The servers currently have 32 cores, 440-something GB of RAM, and the disk containing the DB data uses Azure premium storage with around 700 GB of storage (we currently use 340).

    > And since a hot standby can only service reads (and afaik this is not a
    > well-supported option in PgSQL), wouldn't most of the performance issues,
    > which appear write-related, remain? The process seriously needs to be
    > reviewed here.
Based on our monitoring data we have vastly more reads than writes. This means load balancing gets very interesting. Hot standby is also supported just fine out of the box, you just need something third party for the actual load balancing.

    > And am I reading this right, the one and only production DB server was
    > restarted to change a configuration value in order to try to make
    > pg_basebackup work?
We suspect so. Chef handles restarting processes and we think it's currently still set to do a hard restart always, instead of doing a reload whenever possible.

    > What impact did that have on the people trying to use the site a) while the
    > database was restarting
A few minutes of downtime as the DB is unavailable.

    > and b) while the kernel settings were tweaked to accommodate the too-high
    > max_connections value?
No. We now reduced the max_connections to a lower value (1000) so we still have enough but don't to tweak any kernel settings.

    > Is it normal for GitLab to cause intermittent, few-minute downtimes like
    > that? Or did that occur while the site was already down?
We've had a few too many cases like this in the past. We're aiming to resolve those, but unfortunately this is rather tricky and time consuming.

    > 3. Spam reports can cause mass hard deletion of user data? 
Yes.

    > Has this happened to other users?
Not that I know of.

    > What's the remedy for wrongly-targeted persons?
A better abuse system, e.g. one that makes it easier to see _who_ was reported. We're also thinking of adding a quorom kind of feature: to remove users more than 3 people need to approve it, something like that.

    > And is the GitLab employee's data gone now too?
No. The removal procedure was throwing errors, causing it to roll back its changes. This kept happening, which prevented the user from being removed. So ironically an error saved the day here.

    > How could something so insufficient have been released to the public
Code is written by developers, and developers are humans. Humans in turn make mistakes. Most project removal related code also existed before we started enforcing stricter performance guidelines.

    > and how can you disclose this apparently-unresolved vulnerability? By so
    > doing, you're challenging the public to come and try to empty your database
There's no point in hiding it. Spending a few minutes digging through the code and you'll find it, and probably plenty other similar problems. If somebody tries to abuse it we'll deal with it on a case by case basis.

    > because LVM snapshots now occur hourly, and that it only takes 16 hours to
    > transfer LVM snapshots between environments :)
LVM snapshots are stored on the host itself. As such if e.g. db1 loses data we can restore the snapshot in a few minutes. They only have to be transferred if we want to recover other hosts. Furthermore, in the Azure ARM environment the file transfer would be much faster compared to the classic environment.

    > 4. the PgSQL master deleted its WALs within 4 hours of the replica
    > "beginning to lag" (). That really needs to be fixed.
Yes, which is also something we're looking into.

    > Again, you probably need a serious upgrade to your PgSQL server because it
    > apparently doesn't have enough space to hold more than a couple of hours of
    > WALs (unless this was just a naive misconfiguration of the
    > [min|max]_wal_size parameter, like the max_connections parameter?)
Probably just a naive configuration value since we have plenty of storage available.

    > There were a few other things (including someone else downthread who pointed
    > out that your CEO re-revealed your DB's hostnames in this write-up, and that
    > they're resolvable via public DNS and have running sshds on port 22), but
    > these are the big standouts for me.
Revealing hostnames isn't really a big deal, neither is SSH running on port 22. In the worst case some bots will try to log in using "admin" usernames and the likes, which won't work. All hosts use public key authentication, and password authentication is disabled.

    > Not sure how fast your disks were, but 300GB gone in "a few seconds" sounds
    > like a stretch.
Nope, after about 2 seconds the data was gone. Context: I ran said command.

    > Some data may've been recoverable with some disk forensics.
When using psycial disks not used by anything else, maybe. However, we're talking about disks used in a cloud environment. Are they actually physical? Are they part of larger disks shared with other servers? Who knows. The chance of data recovery using special tools in a cloud environment is basically zero.

    > Especially if your Postgres server was running at the time of the deletion,
    > some data and file descriptors also likely could've been extracted from
    > system memory
That only works for files still held on to by PostgreSQL. PostgreSQL doesn't keep all files open at all times, so it wouldn't help.

Re: Postmortem of database outage of January 31

#187

Earlier quoted context omitted.

I don't think most of your points really apply though. They were setting up replication in production, so they had to work on production boxes. Setting prompt to say just "production" wouldn't help for the same reason. Production was intended. Peer review though - yes. That could help. I wouldn't say "I'm unlikely to make that mistake" - it's likely to go on the famous last words list...

The red PS1 would've clearly indicated to the engineer that he was typing `rm -rf ...` on the _master_, not the secondary. This assumes that the master and secondary would have differing prompts based on their relative importance.

That would help, but that's not what OP advocated. Sure, you can improve on those ideas. I was mainly pointing out that saying "it's unlikely to happen to me" was a bit dangerous and too sure, if most of the reasons do not apply to the situation.

Re: Postmortem of database outage of January 31

#188

I have to say - if they were using a managed relational database service, like Amazon's RDS Postgres, this likely would have never happened. RDS fully automates nightly database snapshots, and ships archive logs to S3 every 5 minutes, which gives you the ability to restore your database to any point in time within the last 35 days, down to the second. Also, RDS gives you a synchronously replicated standby database, a…

RDS has severe performance limitations as in you can't provision more than 30K IOPS which is about 1/2 the performance of low end consumer SSD and about 1/20 the performance of a decent PCI-E SSD. You way better of running on decent dedicated hardware for the DB.

Re: Postmortem of database outage of January 31

#189
TIL GitLab runs on Azure. If your CI servers or deployment targets are also on Azure then the latency should be pretty low (assuming you get the correct region). Good to know.

I moved from AWS to Azure years ago. Mainly because I run mostly .NET workloads and the support is better. I've recently done some .NET stuff on AWS again and am remembering why I switched.

Post reply on HN