Thread: BUG #13864: Reproducible, ERROR: could not read block 30 in file "base/16414/11914": read only 0 of 8192 bytes

The following bug has been logged on the website:

Bug reference:      13864
Logged by:          Prateek Gaur
Email address:      prtkgaur1@gmail.com
PostgreSQL version: 9.4.5
Operating system:   Ubuntu 12.04.5 LTS
Description:

I have a healthy 9.3 postgres backup taken by running
/usr/lib/postgresql/9.3/bin/pg_basebackup -D postgres_clone -l initial -U
postgres -h localhost -p XXX -X stream

After starting postgres from this backup by command :
/usr/lib/9.3/bin/pg_ctl -postgres_clone -l <logpath> start
we run certain commands against this database. These commands are :

BEGIN TRANSACTION;
Create View A;
Create View B;
Create View C; ( Note C builds on top of Views A and B ).
COMMIT;

These commands work fine for postgres version 9.3.

But after upgrading to version 9.4.5 with command .
/usr/lib/postgresql/9.4/bin/pg_upgrade \

    -b /usr/lib/postgresql/9.3/bin/pg_upgrade \

    -B /usr/lib/postgresql/9.4/bin/pg_upgrade \

    -d ./postgres_clone \
    -D ./9.4_postgres_clone \
    -U postgres -v

and starting a 9.4 database with : /usr/lib/9.4/bin/pg_ctl -postgres_clone
-l <logpath> start

The commands described above end up in a failure message 'ERROR:  could not
read block 30 in file "base/16414/11914": read only 0 of 8192 bytes'.
The failure happens while running Create View C.
The failure is very deterministic after upgrading to postgres 9.4.5 but
never happens if I stick to version 9.3.

But interestingly when I break above set of commands into two transactions.
Something like :
BEGIN TRANSACTION;
Create View A;
Create View B;
COMMIT;
BEGIN TRANSACTION;
Create View C;
COMMIT:

I stop seeing the failure for version 9.4.5

Unfortunately I can't use this fix as I want the three statements to be a
part of a single transaction.

Have we seen a scenario where 'could not read block ... ' goes away by
pre-apending a 'COMMIT' statement to the the offending statement?
prtkgaur1@gmail.com writes:
> The commands described above end up in a failure message 'ERROR:  could not
> read block 30 in file "base/16414/11914": read only 0 of 8192 bytes'.

Could we see a self-contained example of this, please?

It'd also be useful to know what you get from

    select relname from pg_class where pg_relation_filenode(oid) = 11914;

in this database.

            regards, tom lane