Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9266


Ignore:
Timestamp:
03/01/13 14:25:49 (12 years ago)
Author:
ascheibe
Message:

#2019 disable lazy loading in some methods to avoid deadlocks

Location:
trunk/sources
Files:
4 edited

Legend:

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

    r7259 r9266  
    2424namespace HeuristicLab.Services.Hive.DataAccess {
    2525  public interface ITransactionManager {
    26     void UseTransaction(Action call, bool serializable = false, bool longRunning = false);
    27     T UseTransaction<T>(Func<T> call, bool serializable = false, bool longRunning = false);
     26    void UseTransaction(Action call, bool repeatableRead = false, bool longRunning = false);
     27    T UseTransaction<T>(Func<T> call, bool repeatableRead = false, bool longRunning = false);
    2828  }
    2929}
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Convert.cs

    r9123 r9266  
    7979      }
    8080    }
     81
     82    public static void ToEntityTaskOnly(DT.Task source, DB.Task target) {
     83      if ((source != null) && (target != null)) {
     84        target.TaskId = source.Id;
     85        target.CoresNeeded = source.CoresNeeded;
     86        target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
     87        target.MemoryNeeded = source.MemoryNeeded;
     88        target.ParentTaskId = source.ParentTaskId;
     89        target.Priority = source.Priority;
     90        target.LastHeartbeat = source.LastHeartbeat;
     91        target.State = Convert.ToEntity(source.State);
     92        target.IsParentTask = source.IsParentTask;
     93        target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
     94        target.Command = Convert.ToEntity(source.Command);
     95        // RequiredPlugins are added by Dao
     96        target.JobId = source.JobId;
     97        target.IsPrivileged = source.IsPrivileged;
     98      }
     99    }
    81100    #endregion
    82101
  • trunk/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs

    r9259 r9266  
    120120    }
    121121
    122     public void UpdateTask(DT.Task dto) {
     122    public void UpdateTaskAndStateLogs(DT.Task dto) {
    123123      using (var db = CreateContext()) {
    124124        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id);
    125125        if (entity == null) db.Tasks.InsertOnSubmit(DT.Convert.ToEntity(dto));
    126126        else DT.Convert.ToEntity(dto, entity);
     127        db.SubmitChanges();
     128      }
     129    }
     130
     131    public void UpdateTask(DT.Task dto) {
     132      using (var db = CreateContext()) {
     133        db.DeferredLoadingEnabled = false;
     134
     135        var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id);
     136        if (entity == null) db.Tasks.InsertOnSubmit(DT.Convert.ToEntity(dto));
     137        else DT.Convert.ToEntityTaskOnly(dto, entity);
    127138        db.SubmitChanges();
    128139      }
     
    186197    public DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
    187198      using (var db = CreateContext()) {
    188         var job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
    189         job.State = taskState;
     199        db.DeferredLoadingEnabled = false;
     200
    190201        db.StateLogs.InsertOnSubmit(new StateLog {
    191202          TaskId = taskId,
     
    197208        });
    198209        db.SubmitChanges();
    199         job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
    200         return DT.Convert.ToDto(job);
     210      }
     211
     212      using (var db = CreateContext()) {
     213        db.DeferredLoadingEnabled = false;
     214
     215        var task = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
     216        task.State = taskState;
     217        db.SubmitChanges();
     218        return DT.Convert.ToDto(task);
    201219      }
    202220    }
     
    615633    public void AssignJobToResource(Guid taskId, IEnumerable<Guid> resourceIds) {
    616634      using (var db = CreateContext()) {
     635        db.DeferredLoadingEnabled = false;
     636
    617637        List<AssignedResource> assignedResources = new List<AssignedResource>();
    618638        foreach (Guid rId in resourceIds) {
  • trunk/sources/HeuristicLab.Services.Hive/3.3/Interfaces/IHiveDao.cs

    r9257 r9266  
    3535    Guid AddTask(DT.Task dto);
    3636    void UpdateTaskAndPlugins(DT.Task dto);
     37    void UpdateTaskAndStateLogs(DT.Task dto);
    3738    void UpdateTask(DT.Task dto);
    3839    void DeleteTask(Guid id);
Note: See TracChangeset for help on using the changeset viewer.