|
|
Log in / Subscribe / Register

Changing Fedora's shutdown timeouts

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 2:13 UTC (Tue) by Wol (subscriber, #4433)
In reply to: Changing Fedora's shutdown timeouts by madscientist
Parent article: Changing Fedora's shutdown timeouts

> Any "database" which is corrupted by a hard stop cannot be called a "database".

You're making the exact same mistake the filesystem guys did at the transition from ext3 to ext4. The users don't give a damn about the filesystem, or the database. THEY CARE ABOUT THEIR DATA.

By journalling the filesystem metadata, ext4 reduced the need for a fsck and sped up boot times after a crash. The problem was, ext3 saved the user's data in the event of a crash, ext4 corrupted it. The user doesn't give a monkeys if the system recovers 10 minutes quicker, if the result is waiting ten hours for your corrupted files to be recovered from a backup.

Likewise, users don't give a monkeys that the database recovers quickly by replaying a journal, if the database has been corrupted by losing "data in flight". If the system crashes with a power outage, then maybe it's acceptable, it's hard to protect 100% against it. But (as we are discussing here) for data in flight to get lost because the system can't be bothered to wait for the database to flush its buffers? THAT IS TOTALLY UNACCEPTABLE. My employer is a supermarket. If customers commit a transaction, the LAST thing we want is for the system to "crash" and lose those transactions. But if the system does not give the database time to flush those transactions to the log, that is exactly what will happen.

It all depends what you mean by "a corrupted database". To you it means a database where the file STRUCTURE is damaged and needs to be repaired. To me it means a database where the file CONTENTS have been damaged, and may be irretrievably lost.

Cheers,
Wol


to post comments

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 2:23 UTC (Tue) by pizza (subscriber, #46) [Link]

> THAT IS TOTALLY UNACCEPTABLE.

Fortunately (and it seems to be repeatedly lost in the "discussion") daemons that can result in data loss if shut down uncleanly already can (and do) override the force-kill timeouts (or actively set shutdown inhibitors).

But this change isn't intended to affect "well-behaved" stuff like the above, but rather stuff that's well and truly hung. Part of this change is to change the signal being sent so that killing the process triggers a core dump, which in turn will get reported out through abrt/etc if the user/admin so chooses, which in turn will allow these misbehaving things to be seen and properly dealt with.

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 9:16 UTC (Tue) by brunowolff (guest, #71160) [Link] (4 responses)

If the application is doing this correctly, then committed transactions won't get lost. The application shouldn't report a transaction as committed until after the database says it is.

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 9:35 UTC (Tue) by Wol (subscriber, #4433) [Link] (3 responses)

And you're missing the point COMPLETELY. By the USERS' DEFINITION, the database is corrupt.

The database STRUCTURE may be perfectly okay. That's no use to me if I've lost a thousand or so customer transactions because the user interface didn't have time to flush to the transaction log ...

The database is protecting ITSELF. It is not successfully protecting the user's data. THAT is the problem.

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 11:31 UTC (Tue) by mjg59 (subscriber, #23239) [Link] (2 responses)

Why is the database informing clients that data is committed if the data is not actually committed?

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 11:37 UTC (Tue) by Wol (subscriber, #4433) [Link] (1 responses)

Because the layer below lied to it? Because hardware lies?

At the end of the day, I DON'T KNOW. But I've seen enough stories about lying for benchmarks, to make me very wary of trusting an acknowledgement further than I can throw it.

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 25, 2023 4:34 UTC (Wed) by mjg59 (subscriber, #23239) [Link]

If hardware lies, how do you know any form of shutdown will result in the data ending up on disk? Either the database knows it's hit disk (in which case it can delay sending confirmation until it knows that) or it doesn't (in which case it doesn't matter how you shut down, there's still a chance of data loss)

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 9:38 UTC (Tue) by kleptog (subscriber, #1183) [Link] (7 responses)

> My employer is a supermarket. If customers commit a transaction, the LAST thing we want is for the system to "crash" and lose those transactions. But if the system does not give the database time to flush those transactions to the log, that is exactly what will happen.

Then that database is broken. Once the database acknowledges the COMMIT from the user, it must not lose the transaction, even if the power fails, SIGKILL, whatever (asteroid impact may be an exception). If you require synchronisation with other systems, you have two-phase commit where the decision whether a transaction will be committed or aborted can be made even after a crash and restart.

There are many ways to do this, usually the database has it's own transaction log. For individual files you have the write/sync/rename trick which every editor should be doing. You're right that the file-system doesn't guarantee anything without using one of the *sync() syscalls, it's debatable whether it should.

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 9:49 UTC (Tue) by Wol (subscriber, #4433) [Link] (6 responses)

> Then that database is broken. Once the database acknowledges the COMMIT from the user, it must not lose the transaction, even if the power fails, SIGKILL, whatever (asteroid impact may be an exception). If you require synchronisation with other systems, you have two-phase commit where the decision whether a transaction will be committed or aborted can be made even after a crash and restart.

"The decision to commit or abort". LOOK AT IT FROM THE USER'S POINT OF VIEW. That decision is a no-brainer. ABORT IS UNACCEPTABLE.

Everybody's looking at it from the database's POV - "protect the database". Nobody's looking at it from the user's POV - "protect the data".

The correct sequence of events is the user confirms checkout, the database accepts the transaction, flushes it to the log, and doesn't return "purchase confirmed" until that log is safely on disk.

But if you've got a bunch of containers/vms/whatever on a machine in the cloud/your own cloud, can you guarantee that that log is safe? With all those layers of indirection in the way? Especially if the *container* confirms receipt of the log to the database, without the container itself checking that the layer below - and the layer below that etc etc - has really truly flushed the transaction? It's Russian Roulette.

Yup. If the software is well written, everything is fine. But can you guarantee that the stack is behaving as you expect / as it should?

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 10:04 UTC (Tue) by unilynx (guest, #114305) [Link]

> But if you've got a bunch of containers/vms/whatever on a machine in the cloud/your own cloud, can you guarantee that that log is safe? With all those layers of indirection in the way? Especially if the *container* confirms receipt of the log to the database, without the container itself checking that the layer below - and the layer below that etc etc - has really truly flushed the transaction? It's Russian Roulette

That's the easy part. And even in your simple scenario without containers, there is a possibility that the data was actually committed but we were unable to tell the user. Containers/VMs/clouds/layers only add some additional latency to these scenarios. And the final result is easy: either the change is committed or it isn't

(yep, you have to assume the layers are bugfree - but I've seen more dataloss with local systems ('confirmed' data not actually persisted) than with cloud volumes)

It gets harder when you need to persist something to multiple locations (spare/multimaster databases, a database and a payment system) because you can't atomically commit over both systems and need to deal with 2 phase commits, split brains, and all that fun.

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 14:32 UTC (Tue) by pizza (subscriber, #46) [Link] (3 responses)

> "The decision to commit or abort". LOOK AT IT FROM THE USER'S POINT OF VIEW. That decision is a no-brainer. ABORT IS UNACCEPTABLE.

Sure, and here's another pony for the user's menagerie.

(If it's so "unacceptable" then the user is paying top $$$$ for systems, software, and expertise to prevent this sort of thing from happening. Otherwise it's just a deluded naive fantasy)

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 16:25 UTC (Tue) by Wol (subscriber, #4433) [Link] (2 responses)

And the contractor is making megabucks using wet-behind-the-ears consultants just out of Uni with no real-world experience ...

What! Me? Cynical???

I would have thought we had plenty of decent staff looking after our systems, but given the steady trickle of emails where we've had a double-commit here, lost data there, ... okay these are user-level errors not database-level, but ...

Given that your average member of staff is, well, average, defensive programming should be the norm, not the exception.

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 16:47 UTC (Tue) by pizza (subscriber, #46) [Link] (1 responses)

> Given that your average member of staff is, well, average, defensive programming should be the norm, not the exception.

Don't forget that "Defensive programming" also includes "design your services to be robust in the face of sudden failures" (and the corollary "sudden failures WILL happen")

This now-decade-old slide deck from Netflix is quite informative in that respect:

https://www.slideshare.net/adrianco/high-availability-arc...

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 17:22 UTC (Tue) by Wol (subscriber, #4433) [Link]

Very interesting read (apart from the damn ads every few slides!!!).

I noticed they use a NoSQL database ... :-)

Now to try and get my lot to use a proper database instead of BigQuery (and Oracle) and a bunch of Excel spreadsheets. So long as they don't insist I use a hammer I'll be happy :-)

BigQuery's own documentation says it's OLAP, and not to use it for OLTP, so if they insist I use BigQuery and Google Sheets to write our production database I will *not* be happy ... oh well, lemmings will be lemmings ...

Cheers,
Wol

Changing Fedora's shutdown timeouts

Posted Jan 24, 2023 18:37 UTC (Tue) by james (guest, #1325) [Link]

LOOK AT IT FROM THE USER'S POINT OF VIEW. That decision is a no-brainer. ABORT IS UNACCEPTABLE.
What if the transaction arrives 2 ms later, when the database is already down? That transaction is not going to be applied.

So you need support for telling the user "that transaction couldn't be committed" anyway.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds