I'm new into postgresSQL, in my course in "Advance database" we are given a problem to simulate a crash at given location in postgres, is anyone got an idea how to make a crash?
BEGIN;
UPDATE actor SET first_name = 'penny' WHERE actor_id = 1;
-- CRASH
COMMIT;
I tested divide by zero but it didn't crash and it only shows an error message! I searched all over the internet but fin nothing about it, anybody knows how to do it?
You could write a custom function in "C" - that would be able to send the KILL signal.
If this doesn't need to be a frequent occurrence though, you can just call pg_sleep with a suitable delay and then send the signal manually (as root or the postgres user).
Note that this is not exactly what people generally think about when simulating a database crash. What you generally do there is disconnect the power rather than just kill the postgres process itself. That tests the whole path down through the operating system and checks the data really, truly gets persisted to the disk (or not) cleanly. That is a lot more work though, particularly with any sort of interesting (so complex, expensive, slow to restart) disk system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With