Re: TOAST corruption in standby database

From: "postgresql_2016(at)163(dot)com" <postgresql_2016(at)163(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: TOAST corruption in standby database
Date: 2019-10-28 15:57:04
Message-ID: 1572278224596-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

SELECT ctid, chunk_id, chunk_seq, md5(chunk_data) FROM
pg_toast.pg_toast_16103925 WHERE chunk_id = 64265646;
ctid | chunk_id | chunk_seq | md5
------+----------+-----------+-----
(0 rows)

SELECT count(1) FROM pg_toast.pg_toast_16103925 WHERE chunk_id = 64265646;
count
-------
2
(1 row)

From the aboving query,I think the problem is form the index. First query
use the default toast index (chunk_id, chunk_seq) to search, it's found
none. The second query use the seq scan and find two matched rows. So I
think the index store value maybe not match the heap tuple. If have the
corruption toast data, I think we can use the tool to see the index and heap
tuple data.

typedef struct IndexTupleData
{
ItemPointerData t_tid; /* reference TID to heap tuple */

/* ---------------
* t_info is laid out in the following fashion:
*
* 15th (high) bit: has nulls
* 14th bit: has var-width attributes
* 13th bit: AM-defined meaning
* 12-0 bit: size of tuple
* ---------------
*/

unsigned short t_info; /* various info about tuple */

} IndexTupleData; /* MORE DATA FOLLOWS AT END OF STRUCT */

In my env, I encounter many cases like "missing chunk number 0 for toast
value XXX in pg_toast_2619" after shutdown the service forcely without
stopping the database. The 2619 is the pg_statistic which is update
frequently.

--
Sent from: https://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-10-28 15:57:21 Re: strpos behavior change around empty substring in PG12
Previous Message Robert Haas 2019-10-28 15:48:49 Re: strpos behavior change around empty substring in PG12