Subject RE: [ib-support] Problem with simultaneous transactions.
Author Wilson, Fred
Quick answer:
To do this properly (mulit-threaded application, with more than one thread
accessing the database), each thread needs its own connection.


Best regards,
Fred Wilson
SE, Bell & Howell
fred.wilson@...



-----Original Message-----
From: ted_hols [mailto:t.francis@...]
Sent: Wednesday, August 21, 2002 10:16 AM
To: ib-support@yahoogroups.com
Subject: [ib-support] Problem with simultaneous transactions.


Hi - I'm developing a multi-threaded application to access the
Firebird database, and I'm finding my threads getting blocked
on simultaneous calls to the Interbase API

I have a DB wrapper class with a set of functions that carry out
particular tasks on the DB.

I have declared separate transaction handles for each of the
particular functions, to allow, say, record X to be added to the
database at the same time as record A being deleted.

I'm currently using embedded SQL:

isc_tr_handle thAddRecord = 0L;
isc_tr_handle thDeleteRecord = 0L;

AddRecord( int nKey )
{
EXEC SQL
SET TRANSACTION NAME thAddRecord READ WRITE;


EXEC SQL
INSERT TRANSACTION thAddRecord
INTO MY_TABLE( ROW_ID ) VALUES( :nKey );

EXEC SQL
COMMIT TRANSACTION thAddRecord;
}

and a similar thing for a DeleteRecord() function.

However, if one thread is calling the AddRecord function, and has its
transaction open, and then at the same time another thread calls the
DeleteRecord function (for a different row), I find that both threads
get blocked:

AddRecord blocks on isc_start_and_send statement
DeleteRecord blocks on isc_start_transaction statement


I've tried declaring the transactions to use both WAIT and NO WAIT
and it makes no difference, and they're using the default isolation
level of SNAPSHOT (isc_tpb_concurrency).

Can anyone see what am I missing?




To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/