-- ---------------------------------------------------------------------- -- SQLSTATE of an injected .cfp read (pread EIO) failure. -- -- cfs_debug_fail_read makes the next record read of .cfp fail with EIO. -- The low-level WARNING uses errcode_for_file_access() (58030 for EIO), -- and the ERROR reported to the client must be ERRCODE_IO_ERROR (58030) -- as well, like md.c for a failed read -- not XX000. The corruption -- route (checksum/format) is NOT covered here: it keeps its own -- reporting (cfs_report_corruption, XX001 by default). -- -- The GUC is PGC_SIGHUP: the in-session reload pattern follows -- dia_plan_cache_index.sql (reload + short sleep). The injection -- counter is spent by the first failing read; the server must stay up -- and the next read must succeed. -- ---------------------------------------------------------------------- SET client_min_messages = warning; CREATE EXTENSION IF NOT EXISTS pg_buffercache; RESET client_min_messages; CREATE TABLE te (id int, v text) WITH (algorithm='zstd'); INSERT INTO te SELECT g, md5(g::text) FROM generate_series(1, 1000) g; CHECKPOINT; SELECT pg_buffercache_evict_relation('te'); ALTER SYSTEM SET cfs_debug_fail_read = 1; SELECT pg_reload_conf(); SELECT pg_sleep(1); DO $$ DECLARE code text; BEGIN BEGIN PERFORM count(*) FROM te; RAISE NOTICE 'read unexpectedly succeeded'; EXCEPTION WHEN OTHERS THEN GET STACKED DIAGNOSTICS code = RETURNED_SQLSTATE; RAISE NOTICE 'sqlstate=%', code; END; END $$; ALTER SYSTEM RESET cfs_debug_fail_read; SELECT pg_reload_conf(); SELECT pg_sleep(1); -- The server survived the IO error; the next read succeeds. SELECT count(*) FROM te; DROP TABLE te;