Answered The deadlock_pripority is always 10 for sync framework

  • 2012年4月13日 8:40
     
     

    Sometimes, deadlock happened with sync framework on my system,

    And the deadlock_priority is 10  for sync framework 2.1 by enable traceon 1222,

    I know that the sql server will determines the session to be a deadlock victime by evaluating the cost of undoing the transaction of the participating sessions, and it selects the onw with the least cost

    But when some dead lock happened, I want the sync framework as the deadlock victim

    I don't like the setting "set deadlock_priority low" for every store procedure for sync framework, _selectchang, _insert....

    Does anybody have any idea on it??

    Regards,

    Abby


    Get reply from social.microsoft

すべての返信

  • 2012年4月13日 8:55
    モデレータ
     
     

    there is no property in Sync Framework to allow you to set that.

    this is a wild shot and am not sure if it will work if you piggy back on the CreateEnumerationTransaction

    but try overriding the CreateEnumerationTransaction and set the deadlock priority from there...

    for an example, have a look at file OracleDbSyncProvider in the sample Oracle Sync Provider: http://code.msdn.microsoft.com/Database-Sync-Oracle-and-037fb083

  • 2012年4月13日 16:44
     
     

    Thanks,

    But how can I set the deadlock priority using sqlconnection?

    It seems that there is property about deadlock priority by using sqlconnection

    Regards,

    Abby


    Get reply from social.microsoft

  • 2012年4月14日 2:20
    モデレータ
     
     
    am not sure there is a connection string property you can set for that... you will have to send the sql command to set it similar to the approach i posted above...
  • 2012年4月19日 14:26
     
     

    It is to set the isolation level, and it seems that there is no property to set the deadlock_priority.

    Thanks,


    Get reply from social.microsoft

  • 2012年4月20日 2:51
    モデレータ
     
     回答済み

    what im saying is in addition to the set isolation level command in there, add another command calling set deadlock_priority explicitly. as i have mentioned already, there is no sync framework property for you set the deadlock priority. so you have to fire the command itself during a sync session.

    • 回答としてマーク Abby.Tang 2012年4月20日 7:54
    •  
  • 2012年4月20日 7:55
     
     

    I will add a new command to set the deadlock priority

    Appreciate for your help.


    Get reply from social.microsoft

  • 2012年5月3日 1:20
     
     回答済み

    override the base method,   

    protected override IDbTransaction CreateApplicationTransaction()
        {
            //The transaction will be used to apply changes to the database
            IDbTransaction trans = this.Connection.BeginTransaction(IsolationLevel.ReadCommitted);
            //execute the command to set the "deadlock_priority" for sync part
            SqlCommand command = new SqlCommand("SET DEADLOCK_PRIORITY LOW", (SqlConnection)this.Connection, (SqlTransaction)trans);
            command.ExecuteNonQuery();
            return trans;
            //return base.CreateApplicationTransaction();
        }


    Get reply from social.microsoft

    • 回答としてマーク Abby.Tang 2012年5月3日 1:21
    •