Subject | Problem with simultaneous transactions. |
---|---|
Author | ted_hols |
Post date | 2002-08-21T17:16:29Z |
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?
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?