Created
March 26, 2024 10:32
-
-
Save cabecada/e9000dec167c831e315668757f56b479 to your computer and use it in GitHub Desktop.
playing with corruption postgres one file at a time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
playing with corruption | |
initdb -D db1 --data-checksums 2>/dev/null >/dev/null | |
pg_ctl -D db1 -l db1.log start | |
psql <<EOF | |
create table t(col1 int primary key, col2 int); | |
create table t2(col1 int references t(col1) on update cascade on delete cascade); | |
insert into t select generate_series(1, 100); | |
insert into t2 select generate_series(1, 100); | |
EOF | |
pg_basebackup -D db2 -R -c fast -C -S db2 -d "port=5432" | |
echo 'port=5433' >> db2/postgresql.auto.conf | |
pg_ctl -D db1 -l db1.log stop | |
pg_ctl -D db2 -l db2.log stop | |
find db1 -type f | xargs -I% dd if=/dev/urandom of=% bs=8k count=10 conv=notrunc,noerror | |
lets recover db1 | |
for fun ....(and then we know the need of replica/backup/what each folder has and log messages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment