Re: POC: Cache data in GetSnapshotData()
От | Mithun Cy |
---|---|
Тема | Re: POC: Cache data in GetSnapshotData() |
Дата | |
Msg-id | CAD__OugYQmNP5dFkGdSjP48B8WjD0+rtff3iupThnQxTXLEUog@mail.gmail.com обсуждение исходный текст |
Ответ на | POC: Cache data in GetSnapshotData() (Andres Freund <andres@2ndquadrant.com>) |
Ответы |
Re: POC: Cache data in GetSnapshotData()
Re: POC: Cache data in GetSnapshotData() |
Список | pgsql-hackers |
On Mon, Jan 4, 2016 at 2:28 PM, Andres Freund <andres@anarazel.de> wrote:
> I think at the very least the cache should be protected by a separate
> lock, and that lock should be acquired with TryLock. I.e. the cache is
> updated opportunistically. I'd go for an lwlock in the first iteration.
Errors are
DETAIL: Key (bid)=(24) already exists.
STATEMENT: UPDATE pgbench_branches SET bbalance = bbalance + $1 WHERE bid = $2;
client 17 aborted in state 11: ERROR: duplicate key value violates unique constraint "pgbench_branches_pkey"
DETAIL: Key (bid)=(24) already exists.
client 26 aborted in state 11: ERROR: duplicate key value violates unique constraint "pgbench_branches_pkey"
DETAIL: Key (bid)=(87) already exists.
ERROR: duplicate key value violates unique constraint "pgbench_branches_pkey"
DETAIL: Key (bid)=(113) already exists.
After some analysis I think In GetSnapshotData() while computing snapshot.
/*
* We don't include our own XIDs (if any) in the snapshot, but we
* must include them in xmin.
*/
if (NormalTransactionIdPrecedes(xid, xmin))
xmin = xid;
*********** if (pgxact == MyPgXact) ******************
continue;
/*
* We don't include our own XIDs (if any) in the snapshot, but we
* must include them in xmin.
*/
if (NormalTransactionIdPrecedes(xid, xmin))
xmin = xid;
*********** if (pgxact == MyPgXact) ******************
continue;
We do not add our own xid to xip array, I am wondering if other backend try to use
the same snapshot will it be able to see changes made by me(current backend).
I think since we compute a snapshot which will be used by other backends we need to
add our xid to xip array to tell transaction is open.
--
--
Вложения
В списке pgsql-hackers по дате отправления: