Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/19/11 23:21:21 (14 years ago)
Author:
cneumuel
Message:

#1233

  • stability improvements for HiveExperiment and HiveEngine
  • parallelized upload of jobs
  • enabled cancellation of job upload
  • reduced the amount of double-assignment of jobs by an additional check in HeartbeatManager
  • tried to tackle the amount of deadlocks by automatically rerunning transactions
  • some fixes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/TransactionManager.cs

    r6431 r6444  
    2727  public static class TransactionManager {
    2828    public static void UseTransaction(Action call, bool serializable = false, bool longRunning = false) {
    29       TransactionScope transaction = CreateTransaction(serializable, longRunning);
    30       try {
    31         call();
    32         transaction.Complete();
    33       }
    34       finally {
    35         transaction.Dispose();
     29      int n = 10;
     30      while (n > 0) {
     31        TransactionScope transaction = CreateTransaction(serializable, longRunning);
     32        try {
     33          call();
     34          transaction.Complete();
     35          n = 0;
     36        }
     37        catch (System.Data.SqlClient.SqlException e) {
     38          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()));         
     40          if (n <= 0) throw;
     41        }
     42        finally {
     43          transaction.Dispose();
     44        }
    3645      }
    3746    }
    3847
    3948    public static T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false) {
    40       TransactionScope transaction = CreateTransaction(serializable, longRunning);
    41       try {
    42         T result = call();
    43         transaction.Complete();
    44         return result;
     49      int n = 10;
     50      while (n > 0) {
     51        TransactionScope transaction = CreateTransaction(serializable, longRunning);
     52        try {
     53          T result = call();
     54          transaction.Complete();
     55          n = 0;
     56          return result;
     57        }
     58        catch (System.Data.SqlClient.SqlException e) {
     59          n--; // probably deadlock situation, let it roll back and repeat the transaction n times
     60          LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString()));
     61          if (n <= 0) throw;
     62        }
     63        finally {
     64          transaction.Dispose();
     65        }
    4566      }
    46       finally {
    47         transaction.Dispose();
    48       }
     67      throw new Exception("This code should not be reached");
    4968    }
    50    
     69
    5170    private static TransactionScope CreateTransaction(bool serializable, bool longRunning) {
    5271      var options = new TransactionOptions();
     
    5877      if (longRunning)
    5978        options.Timeout = ApplicationConstants.LongRunningDatabaseCommandTimeout;
    60      
     79
    6180      return new TransactionScope(TransactionScopeOption.Required, options);
    6281    }
Note: See TracChangeset for help on using the changeset viewer.