root@:26257/defaultdb> CREATE TABLE wallet (
id bigserial primary key,
name text not null,
gender int,
email text,
first_name text,
last_name text,
creation_date timestamp not null,
situation int,
balance decimal not null,
is_blocked bool,
INDEX (name),
INDEX (situation),
INDEX (is_blocked),
INDEX (balance)
);
CREATE TABLE
root@:26257/defaultdb> insert into wallet (name, creation_date, balance) select 'foo', now(), 1.0 from generate_series(1,100000);
INSERT 100000
root@:26257/defaultdb> CREATE TABLE transaction (
id bigserial primary key,
sender_id bigint REFERENCES wallet(id) ON DELETE CASCADE,
receiver_id bigint REFERENCES wallet(id) ON DELETE CASCADE,
amount decimal not null,
creation_date timestamp not null,
last_update timestamp,
schedule_date timestamp,
status int,
comment text,
linked_trans_id bigint REFERENCES transaction(id) ON DELETE CASCADE,
c1 text,
c2 text,
c3 text,
INDEX (sender_id),
INDEX (receiver_id),
INDEX (linked_trans_id)
);
CREATE TABLE
root@:26257/defaultdb> insert into transaction (sender_id, receiver_id, amount, creation_date, linked_trans_id) select i%100000+1,(i+1)%100000+1,1.0,now(),NULL from generate_series(1,1000000) v(i);
ERROR: insert on table "transaction" violates foreign key constraint "fk_sender_id_ref_wallet"
SQLSTATE: 23503
DETAIL: Key (sender_id)=(2) is not present in table "wallet".
root@:26257/defaultdb> delete from wallet where 1=1;
The last statement hangs indefinitely (or at least longer than the 5 minutes I waited). By contrast, if I haven't run the insert into transaction statement, the delete from wallet where 1=1 completes in ~30s.
Repro:
The last statement hangs indefinitely (or at least longer than the 5 minutes I waited). By contrast, if I haven't run the
insert into transactionstatement, thedelete from wallet where 1=1completes in ~30s.