大量の新しいレコードを ORACLE データベースに一括挿入 (インポート) するメカニズムを作成しています。複数のスレッドと依存トランザクションを使用しています:
スレッドの作成:
const int ThreadCount = 4;
using (TransactionScope transaction = new TransactionScope())
{
List<Thread> threads = new List<Thread>(threadCount);
for (int i = 0; i < ThreadCount; i++)
{
Thread thread = new Thread(WorkerThread);
thread.Start(Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete));
threads.Add(thread);
}
threads.ForEach(thread => thread.Join());
transaction.Complete();
}
実際の作業を行うメソッド:
private void WorkerThread(object transaction)
{
using (DependentTransaction dTx = (DependentTransaction)transaction)
using (TransactionScope ts = new TransactionScope(dTx))
{
// The actual work, the inserts on the database, are executed here.
}
}
この操作中にSystem.Data.OracleClient.OracleException
、メッセージ付きのタイプの例外が発生しますORA-24757: duplicate transaction identifier
。
私は何を間違っていますか?依存トランザクションを間違った方法で実装していますか? Oracle と互換性がありませんか? もしそうなら、回避策はありますか?