public TransactionObjectHeader PreCommit() { if (objInfo.Oid > 0 && objInfo.Oid <= objInfo.SqoTypeInfo.Header.numberOfRecords && !serializer.IsObjectDeleted(objInfo.Oid, objInfo.SqoTypeInfo)) { originalObject = engine.LoadObjectByOID(objInfo.SqoTypeInfo, objInfo.Oid); TransactionObjectHeader header = new TransactionObjectHeader(); header.Operation = this.Operation; header.OIDofObject = engine.metaCache.GetOIDOfObject(originalObject, objInfo.SqoTypeInfo); return header; } return null; }
public async Task<TransactionObjectHeader> PreCommitAsync() { if (objInfo.Oid > 0 && objInfo.Oid <= objInfo.SqoTypeInfo.Header.numberOfRecords && !await serializer.IsObjectDeletedAsync(objInfo.Oid, objInfo.SqoTypeInfo).ConfigureAwait(false)) { originalObject = await engine.LoadObjectByOIDAsync(objInfo.SqoTypeInfo, objInfo.Oid).ConfigureAwait(false); TransactionObjectHeader header = new TransactionObjectHeader(); header.Operation = this.Operation; header.OIDofObject = engine.metaCache.GetOIDOfObject(originalObject, objInfo.SqoTypeInfo); return header; } return null; }
internal static void CommitTransaction(Guid id) { lock (_SyncRoot) { TransactionInternal transactionInternal = transactions[id]; TransactionObjectHeader lastHeader = null; TransactionsStorage transactStorage = transactionInternal.siaqodbInstance.GetTransactionLogStorage(); foreach (SqoTypeInfo ti in transactionInternal.tiInvolvedInTransaction) { transactionInternal.siaqodbInstance.PutIndexPersiststenceState(ti, false); } transactionInternal.siaqodbInstance.TransactionCommitStatus(true); try { foreach (TransactionObject trObj in transactionInternal.transactionObjects) { if (!transactionInternal.nrRecordsBeforeCommit.ContainsKey(trObj.serializer)) { transactionInternal.nrRecordsBeforeCommit.Add(trObj.serializer, new KeyValuePair <SqoTypeInfo, int>(trObj.objInfo.SqoTypeInfo, trObj.objInfo.SqoTypeInfo.Header.numberOfRecords)); TransactionTypeHeader tHeader = new TransactionTypeHeader(); tHeader.NumberOfRecords = trObj.objInfo.SqoTypeInfo.Header.numberOfRecords; tHeader.TypeName = trObj.objInfo.SqoTypeInfo.TypeName; transactionInternal.siaqodbInstance.StoreObject(tHeader); transactionInternal.siaqodbInstance.Flush <TransactionTypeHeader>(); } TransactionObjectHeader header = trObj.PreCommit(); if (header != null) { if (lastHeader != null) { header.Position = lastHeader.Position + lastHeader.BatchSize; } SaveObjectForCrashRollback(trObj.originalObject, trObj.objInfo.SqoTypeInfo, transactStorage, header, trObj.engine); SaveHeader(header, transactionInternal.siaqodbInstance); lastHeader = header; } transactionInternal.siaqodbInstance.circularRefCache.Add(trObj.currentObject); trObj.Commit(); } } finally { transactStorage.Close(); transactionInternal.siaqodbInstance.TransactionCommitStatus(false); } foreach (SqoTypeInfo ti in transactionInternal.tiInvolvedInTransaction) { transactionInternal.siaqodbInstance.PutIndexPersiststenceState(ti, true); transactionInternal.siaqodbInstance.PersistIndexDirtyNodes(ti); } transactions.Remove(id); transactionInternal.siaqodbInstance.DropType <TransactionObjectHeader>(); transactionInternal.siaqodbInstance.DropType <TransactionTypeHeader>(); transactionInternal.siaqodbInstance.DropTransactionLog(); transactionInternal.transaction.status = TransactionStatus.Closed; transactionInternal.siaqodbInstance.Flush(); } }
private static async Task SaveHeaderAsync(TransactionObjectHeader header, Siaqodb siaqodb) { await siaqodb.StoreObjectAsync(header).ConfigureAwait(false); await siaqodb.FlushAsync <TransactionObjectHeader>().ConfigureAwait(false); }
private static void SaveHeader(TransactionObjectHeader header, Siaqodb siaqodb) { siaqodb.StoreObject(header); siaqodb.Flush <TransactionObjectHeader>(); }
private static async Task SaveObjectForCrashRollbackAsync(object obj, SqoTypeInfo ti, TransactionsStorage storage, TransactionObjectHeader header, StorageEngine engine) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, engine.metaCache); byte[] bytes = await engine.GetObjectBytesAsync(objInfo.Oid, ti).ConfigureAwait(false); int batchSize = await storage.SaveTransactionalObjectAsync(bytes, header.Position).ConfigureAwait(false); await storage.FlushAsync().ConfigureAwait(false); header.BatchSize = batchSize; header.TypeName = ti.TypeName; }
private static void SaveObjectForCrashRollback(object obj, SqoTypeInfo ti, TransactionsStorage storage, TransactionObjectHeader header, StorageEngine engine) { ObjectInfo objInfo = MetaExtractor.GetObjectInfo(obj, ti, engine.metaCache); byte[] bytes = engine.GetObjectBytes(objInfo.Oid, ti); int batchSize = storage.SaveTransactionalObject(bytes, header.Position); storage.Flush(); header.BatchSize = batchSize; header.TypeName = ti.TypeName; }