Questions on extending a relation

Поиск
Список
Период
Сортировка
От Qingqing Zhou
Тема Questions on extending a relation
Дата
Msg-id d9p0i4$bk5$1@news.hub.org
обсуждение исходный текст
Ответы Re: Questions on extending a relation  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi Hackers,

Here I have two questions related to extending a relation:

1. When we want a new page, we will do something like this:

LockPage(relation, 0, ExclusiveLock);
blockNum = smgrnblocks(reln->rd_smgr);
/* Try to locate this blockNum in buffer pool, but definitely can't? */
smgrextend(blockNum);
LockPage(relation, 0, ExclusiveLock);

So if I have concurrently 10 backends reach here, we will have 10 new pages?
Suppose they all insert one new tuple, commit, then quit. Next time when
they connected again, they only reuse the last page, so we almost lost 9
pages?

2. Suppose an insert on a relation with index is performed in this sequence:

begin transation;
extend relation for a new page A;
insert a heap tuple T on page A;
insert an index tuple I on another page B;
page B get written out by bgwriter;
System crashed.
System recovered.

At this time, page A is empty since we won't replay xlog. Now we insert a
heap tuple on page A again, which will use the same slot of the tuple T. So
now the index tuple I points to T?

Thanks a lot,
Qingqing





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

Предыдущее
От: "Magnus Hagander"
Дата:
Сообщение: tsearch2 vs core?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: contrib/rtree_gist into core system?