pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jesse@falkon.ai
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16595: Reads fail with "lost saved point in index" error after writes
Date: Thu, 27 Aug 2020 11:01:04 -0400
Message-ID: <3032572.1598540464@sss.pgh.pa.us> (raw)
In-Reply-To: <16595-633118be8eef9ce2@postgresql.org>
References: <16595-633118be8eef9ce2@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> The table in question has a JSONB column with a GIN index, defined as:
> "index_name_idx" gin (jsonb_column_name jsonb_path_ops, integer_column,
> timestamp_with_time_zone_column)
> Under load (especially writes followed immediately by reads), we
> occasionally see reads failing an internal exception (error code XX000) with
> the message "lost saved point in index".

[ stares at that for awhile... ]  Hm, I think this is just broken for
multi-column GIN indexes.  The code is expecting that it can re-find
an index item that was there before, and that the item must either be
where it was before in the index or somewhere to the right.  Both
of those assumptions seem valid, since ginvacuum never removes items;
but insertions could push the item to the right.

But this:

                if (gintuple_get_attrnum(btree->ginstate, itup) != attnum)
                    elog(ERROR, "lost saved point in index");    /* must not happen !!! */

amounts to an assumption that things can't get pushed so far to the
right that our pointer is now pointing at an item with lower attnum.
There's no reason for that to be true --- AFAICS, the attnum is the
first sort key for the items, but there's not physical segregation
into different index pages or anything like that.

We could throw an error if we reach a higher attnum, but since the
whole thing is supposed to be can't-happen, I doubt it's worth
expending code on.  What we should do is just advance over any
item that hasn't got the right attnum.

			regards, tom lane





view thread (5+ messages)  latest in thread

Message-ID: <3032572.1598540464@sss.pgh.pa.us>
Permalink:  ../3032572.1598540464@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3032572.1598540464@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jesse@falkon.ai, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16595: Reads fail with "lost saved point in index" error after writes
  In-Reply-To: <3032572.1598540464@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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