Re: [sqlsmith] Crash in GetOldestSnapshot()

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: [sqlsmith] Crash in GetOldestSnapshot()
Дата
Msg-id CAA4eK1LiRxT_iPfJ=uK13tLCtaGAQqn_YOY=6zCBqoi2mW333A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [sqlsmith] Crash in GetOldestSnapshot()  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Ответы Re: [sqlsmith] Crash in GetOldestSnapshot()  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-hackers
On Sat, Aug 6, 2016 at 5:51 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
>>>>>> "Andreas" == Andreas Seltenreich <seltenreich@gmx.de> writes:
>
> 418   if (OldestActiveSnapshot != NULL)
> 419       ActiveLSN = OldestActiveSnapshot->as_snap->lsn;
> 420
> 421   if (XLogRecPtrIsInvalid(RegisteredLSN) || RegisteredLSN > ActiveLSN)
> 422       return OldestActiveSnapshot->as_snap;
>
> This second conditional should clearly be inside the first one...
>

Sure, that is the reason of crash, but even if we do that it will lead
to an error "no known snapshots".  Here, what is going on is that we
initialized toast snapshot when there is no active snapshot in the
backend, so GetOldestSnapshot() won't return any snapshot.  I think
for such situations, we need to initialize the lsn and whenTaken of
ToastSnapshot as we do in GetSnapshotData() [1].  We need to do this
when snapshot returned by GetOldestSnapshot() is NULL.

Thoughts?


[1]
In below code
if (old_snapshot_threshold < 0)
{
..
}
else
{
/*
* Capture the current time and WAL stream location in case this
* snapshot becomes old enough to need to fall back on the special
* "old snapshot" logic.
*/
snapshot->lsn = GetXLogInsertRecPtr();
snapshot->whenTaken = GetSnapshotCurrentTimestamp();
MaintainOldSnapshotTimeMapping(snapshot->whenTaken, xmin);
}


-- 
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Gierth
Дата:
Сообщение: Re: [sqlsmith] Crash in GetOldestSnapshot()
Следующее
От: Andrew Gierth
Дата:
Сообщение: Re: [sqlsmith] Crash in GetOldestSnapshot()