referential integrity preventing simultaneous insert

Поиск
Список
Период
Сортировка
От Edwin Grubbs
Тема referential integrity preventing simultaneous insert
Дата
Msg-id d6b3d4ab04090910533700a02a@mail.gmail.com
обсуждение исходный текст
Ответы Re: referential integrity preventing simultaneous insert  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Hello,

I have experienced problems with postgres hanging when two inserts
reference the same foreign key. It appears that the second insert is
waiting for the first insert to release a lock.
Here is an example of how to recreate the problem. Please ignore the
lack of sequences, since that is irrelevent to the problem. I have
tested this under pg 7.4.3.

----------------------------------------------------------
-- Set up test database:

CREATE TABLE model (
    id INTEGER PRIMARY KEY,
    name varchar(20)
);

CREATE TABLE car (
    id INTEGER PRIMARY KEY,
    model_id INTEGER REFERENCES model
);

INSERT INTO model VALUES (1, 'one');

----------------------------------------------------------
-- First connection opens a transaction and adds a reference to model id=1.
BEGIN; INSERT INTO car VALUES (5, 1);
-- Do not commit this transaction.
----------------------------------------------------------
-- Open a separate connection.
-- Second connection does the same and will hang until the
-- first transaction ends.
BEGIN; INSERT INTO car VALUES (6, 1);
----------------------------------------------------------

Is this fixed in postgres 8? If it still requires work, I may be able
to help fund it to get it completed sooner.

Thanks,
Edwin Grubbs

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

Предыдущее
От: Phil Endecott
Дата:
Сообщение: Re: Obtaining the Julian Day from a date
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: Text Search vs MYSQL vs Lucene