pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPotential BRIN Index Corruption
6+ messages / 3 participants
[nested] [flat]
* Potential BRIN Index Corruption
@ 2020-11-26 00:46 Huan Ruan <leohuanruan@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Huan Ruan @ 2020-11-26 00:46 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi All
We have a table with 623 million records. It appears a BRIN index of this
table on a timestamp column is missing some records, as illustrated below
in a cut-down version with additional columns and indices omitted.
We cannot work out a reproducible case but we have a copy of the offending
database. I was hoping to know
1. if anyone else has experienced similar issues
2. if anyone can shed some light on what to collect in order to fire a
useful bug report
Version
- centos-release-7-7.1908.0.el7.centos.x86_64
- PostgreSQL 10.14 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5
20150623 (Red Hat 4.8.5-39), 64-bit
Table DDL
CREATE TABLE large_table_with_623m_records (
date_with_btree_index date,
ts_with_brin_index timestamp without time zone not null
);
CREATE INDEX date_bree_index ON large_table_with_623m_records
USING btree (date_with_btree_index COLLATE pg_catalog."default"
, date_with_btree_index);
CREATE INDEX ts_brin_index ON large_table_with_623m_records
USING brin (ts_with_brin_index);
Query
SELECT
*
FROM large_table_with_623m_records
WHERE
ts_with_brin_index >= '2018-06-29 12:12:50' AND ts_with_brin_index <
'2018-06-29 12:13:00'
AND date_with_btree_index = '2013-05-21'
This query uses Index Scan on date_bree_index and correctly returns 1
record that has ts_with_brin_index = '2018-06-29 12:12:58:081'.
If I remove the last line (AND date_with_btree_index = '2013-05-21'), the
query uses Bitmap Index Scan on ts_brin_index and incorrectly returns 0
record.
After a reindex of ts_brin_index, both variations of the query correctly
return 1 record.
Thanks
Huan
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Potential BRIN Index Corruption
@ 2020-11-26 02:42 Alvaro Herrera <alvherre@alvh.no-ip.org>
parent: Huan Ruan <leohuanruan@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Alvaro Herrera @ 2020-11-26 02:42 UTC (permalink / raw)
To: Huan Ruan <leohuanruan@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On 2020-Nov-26, Huan Ruan wrote:
> Hi All
>
> We cannot work out a reproducible case but we have a copy of the offending
> database. I was hoping to know
I think the way to debug this would be to see what WAL records have been
emitted for the index, using pageinspect to find the problem index
tuple.
Use 'select ctid rrom large_table_with_623m_records where ...' to
pinpoint the unindexed tuple's page number; see when (in LSN) was that
tuple written; inspect WAL surroundings looking for updates (or lack
thereof) for the BRIN index. Use pageinspect to examine raw brin data.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Potential BRIN Index Corruption
@ 2020-11-26 21:40 Huan Ruan <leohuanruan@gmail.com>
parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 1 reply; 6+ messages in thread
From: Huan Ruan @ 2020-11-26 21:40 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-general@lists.postgresql.org
>
> Thanks Alvaro for pointing me to pageinspect. I will give it a try and
> report back. It might take a few days. I knew this module but have never
> tried it before.
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Potential BRIN Index Corruption
@ 2020-12-08 23:07 Huan Ruan <leohuanruan@gmail.com>
parent: Huan Ruan <leohuanruan@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Huan Ruan @ 2020-12-08 23:07 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-general@lists.postgresql.org
HI Alvaro
Unfortunately those records were written a while ago and we no longer keep
their WAL logs. Thanks for your help anyway.
Huan
On Fri, 27 Nov 2020 at 08:40, Huan Ruan <leohuanruan@gmail.com> wrote:
> Thanks Alvaro for pointing me to pageinspect. I will give it a try and
>> report back. It might take a few days. I knew this module but have never
>> tried it before.
>>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Potential BRIN Index Corruption
@ 2020-12-09 17:01 Tomas Vondra <tomas.vondra@enterprisedb.com>
parent: Huan Ruan <leohuanruan@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tomas Vondra @ 2020-12-09 17:01 UTC (permalink / raw)
To: Huan Ruan <leohuanruan@gmail.com>; Alvaro Herrera <alvherre@alvh.no-ip.org>; +Cc: pgsql-general@lists.postgresql.org
On 12/9/20 12:07 AM, Huan Ruan wrote:
> HI Alvaro
>
> Unfortunately those records were written a while ago and we no longer keep
> their WAL logs. Thanks for your help anyway.
>
Can you estimate when roughly the records were written? E.g. by using a
rough estimate of WAL or XIDs generated per day, or something like that.
Maybe there was some I/O issue in that time period and a couple writes
got lost, or something like that.
Are there any other corrupted indexes on the table?
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Potential BRIN Index Corruption
@ 2020-12-13 23:06 Huan Ruan <leohuanruan@gmail.com>
parent: Tomas Vondra <tomas.vondra@enterprisedb.com>
0 siblings, 0 replies; 6+ messages in thread
From: Huan Ruan @ 2020-12-13 23:06 UTC (permalink / raw)
To: Tomas Vondra <tomas.vondra@enterprisedb.com>; +Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-general@lists.postgresql.org
Hi Tomas
The records have a timestamp column so we do know the time they were
written. We didn't find any I/O issues that match that time but
unfortunately as it's been a while we are not confident with that finding.
> Are there any other corrupted indexes on the table?
That was one of my first questions too. I don't see any physical errors in
pg log so not sure if there are other corruptions. One thing we consider
doing is to turn on checksums.
Regards
Huan
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2020-12-13 23:06 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 00:46 Potential BRIN Index Corruption Huan Ruan <leohuanruan@gmail.com>
2020-11-26 02:42 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2020-11-26 21:40 ` Huan Ruan <leohuanruan@gmail.com>
2020-12-08 23:07 ` Huan Ruan <leohuanruan@gmail.com>
2020-12-09 17:01 ` Tomas Vondra <tomas.vondra@enterprisedb.com>
2020-12-13 23:06 ` Huan Ruan <leohuanruan@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox