Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/28/13 13:57:49 (12 years ago)
Author:
ascheibe
Message:

#2019

  • added missing transactions in the Hive service
  • split scheduling transaction into smaller transactions
  • improved speed of job uploading (AddTask)
  • changed highest isolation level from Serializable to RepeatableRead as phantom reads shouldn't be a problem
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive.DataAccess/3.3/TransactionManager.cs

    r7259 r9257  
    2222using System;
    2323using System.Transactions;
    24 using HeuristicLab.Services.Hive.DataAccess;
    2524
    26 namespace HeuristicLab.Services.Hive.DataAccess { 
    27   public class TransactionManager : ITransactionManager {   
    28     public void UseTransaction(Action call, bool serializable = false, bool longRunning = false) {
     25namespace HeuristicLab.Services.Hive.DataAccess {
     26  public class TransactionManager : ITransactionManager {
     27    public void UseTransaction(Action call, bool repeatableRead = false, bool longRunning = false) {
    2928      int n = 10;
    3029      while (n > 0) {
    31         TransactionScope transaction = CreateTransaction(serializable, longRunning);
     30        TransactionScope transaction = CreateTransaction(repeatableRead, longRunning);
    3231        try {
    3332          call();
     
    3736        catch (System.Data.SqlClient.SqlException e) {
    3837          n--; // probably deadlock situation, let it roll back and repeat the transaction n times
    39           LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString()));         
     38          LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString()));
    4039          if (n <= 0) throw;
    4140        }
     
    4645    }
    4746
    48     public T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) {
     47    public T UseTransaction<T>(Func<T> call, bool repeatableRead = false, bool longRunning = false) {
    4948      int n = 10;
    5049      while (n > 0) {
    51         TransactionScope transaction = CreateTransaction(serializable, longRunning);
     50        TransactionScope transaction = CreateTransaction(repeatableRead, longRunning);
    5251        try {
    5352          T result = call();
     
    6867    }
    6968
    70     private TransactionScope CreateTransaction(bool serializable, bool longRunning) {
     69    private TransactionScope CreateTransaction(bool repeatableRead, bool longRunning) {
    7170      var options = new TransactionOptions();
    72       if (serializable)
    73         options.IsolationLevel = IsolationLevel.Serializable;
     71      if (repeatableRead)
     72        options.IsolationLevel = IsolationLevel.RepeatableRead;
    7473      else
    7574        options.IsolationLevel = IsolationLevel.ReadUncommitted;
Note: See TracChangeset for help on using the changeset viewer.