Thread: BRIN index bug due to WAL refactoring

BRIN index bug due to WAL refactoring

From
Jeff Janes
Date:
BRIN index WAL is broken in HEAD.

Commit 2c03216d831160bedd72d4, the Revamp the WAL record format, is the culprit.

The easiest way to see this is via streaming replication.

On master:

create table foobar as select * from generate_series(1,10000);
create index on foobar using brin (generate_series );

On replica:

set enable_seqscan TO off;
explain (analyze) select count(*) from foobar ;
ERROR:  corrupted BRIN index: inconsistent range map

Cheers,

Jeff

Re: BRIN index bug due to WAL refactoring

From
Alvaro Herrera
Date:
Jeff Janes wrote:
> BRIN index WAL is broken in HEAD.

Thanks for all the details.  Looking into it.



-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



Re: BRIN index bug due to WAL refactoring

From
Alvaro Herrera
Date:
Jeff Janes wrote:

> On replica:
>
> set enable_seqscan TO off;
> explain (analyze) select count(*) from foobar ;
> ERROR:  corrupted BRIN index: inconsistent range map

Nice.  As I understand it, the problem is that the replay is using the
block number of the revmap page as target blkno of the revmap entry,
when it should be using the block number of the data page.  This should
fix it.

--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment

Re: BRIN index bug due to WAL refactoring

From
Jeff Janes
Date:

On Fri, Jun 26, 2015 at 11:35 AM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
Jeff Janes wrote:

> On replica:
>
> set enable_seqscan TO off;
> explain (analyze) select count(*) from foobar ;
> ERROR:  corrupted BRIN index: inconsistent range map

Nice.  As I understand it, the problem is that the replay is using the
block number of the revmap page as target blkno of the revmap entry,
when it should be using the block number of the data page.  This should
fix it.


Thanks, that worked.

The way the blkno and buffer refer to different block/buffers is pretty confusing.  Could we rename a variable to make it clearer which buffer's number is contained in blkno?

Thanks,

Jeff

Re: BRIN index bug due to WAL refactoring

From
Alvaro Herrera
Date:
Jeff Janes wrote:

> The way the blkno and buffer refer to different block/buffers is pretty
> confusing.  Could we rename a variable to make it clearer which buffer's
> number is contained in blkno?

Sure thing.  Pushed that way.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services