title: Setting deadlock_priority does not make LOW priority session the victim
body: <p>One of our jobs was deadlocking with user routines, so we put the following code in the job step, just before the procedure is called:</p>
  
  <pre><code>DECLARE @deadlock_var NCHAR(3);  
  SET @deadlock_var = N'LOW';  
  SET DEADLOCK_PRIORITY @deadlock_var;
  *--Call procedure
  exec Client_myDeliveries_I_S*
  </code></pre>
  
  <p>However, the procedure is still in the stack that is processed.
  <strong>Does the deadlock priority not get inherited through the chain of sub procedures?</strong>
  I can confirm that at no point does the deadlock victim session set its deadlock_priority.</p>
  
  <p>The complete deadlock XML is below, with some deletions for privacy:</p>
  
  <pre><code>&lt;deadlock&gt;
   &lt;victim-list&gt;
    &lt;victimProcess id="process28fc21868" /&gt;
   &lt;/victim-list&gt;
   &lt;process-list&gt;
    &lt;process id="process28fc21868" taskpriority="0" logused="2504" waitresource="KEY: 5:72057594562412544 (40fd182c0dd9)" waittime="5008" ownerId="299034576" transactionname="user_transaction" lasttranstarted="2018-02-01T12:22:55.580" XDES="0x140b2cc70" lockMode="X" schedulerid="1" kpid="3600" status="suspended" spid="87" sbid="0" ecid="0" priority="0" trancount="2" lastbatchstarted="2018-02-01T12:22:55.580" lastbatchcompleted="2018-02-01T12:22:55.580" lastattention="2018-02-01T12:22:52.480" clientapp="EUROSTOP e-i Service" hostname="SRVAZBRWSQL01" hostpid="1328" loginname="sa" isolationlevel="read committed (2)" xactid="299034576" currentdb="5" lockTimeout="4294967295" clientoption1="673316896" clientoption2="128056"&gt;
     &lt;executionStack&gt;
      &lt;frame procname="ALL.dbo.trgi_u_Constants" line="705" stmtstart="37030" stmtend="37270" sqlhandle="0x03000500651fce5aad8fd3002aa5000000000000000000000000000000000000000000000000000000000000"&gt;
  update myconstants
                  set value = (select last_c_no from inserted)
                  where batch = 'last_c_no'    &lt;/frame&gt;
      &lt;frame procname="IF_TEST.myschema.SendTestData_Customers_SToALL_Customers" line="87" stmtstart="11420" stmtend="11650" sqlhandle="0x030007007f19ab663ac3e5005ca7000001000000000000000000000000000000000000000000000000000000"&gt;
  update myschema.ALL_Constants
              set     last_c_no = @nLastCNumber + @NumberOfInsertedCs    &lt;/frame&gt;
      &lt;frame procname="IF_TEST.myschema.SendTestData_Customers" line="22" stmtstart="962" stmtend="1196" sqlhandle="0x030007009c954b7757b4d00054a7000001000000000000000000000000000000000000000000000000000000"&gt;
  exec myschema.SendTestData_Customers_SToALL_Customers @MessageCode, @RejectAllOnValidationError    &lt;/frame&gt;
      &lt;frame procname="IF_TEST.myschema.SendSubmittedFData" line="13" stmtstart="876" stmtend="1114" sqlhandle="0x030007009b4fb66e2db4d00054a7000001000000000000000000000000000000000000000000000000000000"&gt;
  exec [myschema].[SendTestData_Customers] @MessageCode, @RejectAllOnValidationError
  
      -- Customer Orders    &lt;/frame&gt;
      &lt;frame procname="adhoc" line="1" stmtstart="104" sqlhandle="0x010007008547740e50dc4dd90700000000000000000000000000000000000000000000000000000000000000"&gt;
  Exec myschema.SendSubmittedFData @0, @1, @2, @3    &lt;/frame&gt;
      &lt;frame procname="unknown" line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"&gt;
  unknown    &lt;/frame&gt;
     &lt;/executionStack&gt;
     &lt;inputbuf&gt;
  (@0 nvarchar(4000),@1 int,@2 nvarchar(4000),@3 int);Exec myschema.SendSubmittedFData @0, @1, @2, @3   &lt;/inputbuf&gt;
    &lt;/process&gt;
    &lt;process id="process2b6e94cf8" taskpriority="-6" logused="43652" waitresource="KEY: 5:72057594562412544 (d08358b1108f)" waittime="5009" ownerId="299033786" transactionname="user_transaction" lasttranstarted="2018-02-01T12:22:53.810" XDES="0x28262f130" lockMode="X" schedulerid="2" kpid="13408" status="suspended" spid="122" sbid="0" ecid="0" priority="-5" trancount="3" lastbatchstarted="2018-02-01T12:15:00.580" lastbatchcompleted="2018-02-01T12:15:00.580" lastattention="1900-01-01T00:00:00.580" clientapp="SQLAgent - TSQL JobStep (Job 0x24121E41ABD80643985B522FE6C248A7 : Step 1)" hostname="SRVAZBRWSQL01" hostpid="2252" loginname="SRVAZBRWSQL01\ALLSYSTEM" isolationlevel="read committed (2)" xactid="299033786" currentdb="5" lockTimeout="4294967295" clientoption1="673316896" clientoption2="128056"&gt;
     &lt;executionStack&gt;
      &lt;frame procname="ALL.dbo.trgi_u_Constants" line="726" stmtstart="38142" stmtend="38386" sqlhandle="0x03000500651fce5aad8fd3002aa5000000000000000000000000000000000000000000000000000000000000"&gt;
  update myconstants
                  set value = (select last_gs_rec_no from inserted)
                  where batch = 'last_gs_rec_no'    &lt;/frame&gt;
      &lt;frame procname="ALL.dbo.trgi_i_i_I_deliveries" line="1005" stmtstart="69046" stmtend="69220" sqlhandle="0x030005006cd104389a850d00a1a6000000000000000000000000000000000000000000000000000000000000"&gt;
  update dbo.Constants set last_gs_rec_no = last_gs_rec_no + @nmyDeliveriesCreatedCount    &lt;/frame&gt;
      &lt;frame procname="C_HELP.dbo.Client_myDeliveries_I_Std" line="86" stmtstart="7306" stmtend="8324" sqlhandle="0x030006000d09a1438efcba0074a8000001000000000000000000000000000000000000000000000000000000"&gt;
  insert  into [ALL].dbo.i_I_deliveries
                  --[columns]
                  select  --[columns]
                  from    #Client_deliveries_PO_stg stg    &lt;/frame&gt;
      &lt;frame procname="C_HELP.dbo.Client_myDeliveries_I_S" line="446" stmtstart="32832" stmtend="33032" sqlhandle="0x0300060028323b37f7a70101eca7000001000000000000000000000000000000000000000000000000000000"&gt;
  exec  dbo.Client_myDeliveries_I_Std @week_selector, @username, @factory_bin_location, @Parameter    &lt;/frame&gt;
      &lt;frame procname="adhoc" line="6" stmtstart="216" sqlhandle="0x02000000e49e3111676b7e3aec714d06946692f70e3a8a880000000000000000000000000000000000000000"&gt;
  exec Client_myDeliveries_I_S    &lt;/frame&gt;
     &lt;/executionStack&gt;
     &lt;inputbuf&gt;
  DECLARE @deadlock_var NCHAR(3);  
  SET @deadlock_var = N'LOW';  
  
  SET DEADLOCK_PRIORITY @deadlock_var;
  
  exec Client_myDeliveries_I_S   &lt;/inputbuf&gt;
    &lt;/process&gt;
   &lt;/process-list&gt;
   &lt;resource-list&gt;
    &lt;keylock hobtid="72057594562412544" dbid="5" objectname="ALL.dbo.myconstants" indexname="pk_myconstants" id="lockd5ad7b00" mode="RangeS-U" associatedObjectId="72057594562412544"&gt;
     &lt;owner-list&gt;
      &lt;owner id="process2b6e94cf8" mode="RangeS-S" /&gt;
     &lt;/owner-list&gt;
     &lt;waiter-list&gt;
      &lt;waiter id="process28fc21868" mode="X" requestType="convert" /&gt;
     &lt;/waiter-list&gt;
    &lt;/keylock&gt;
    &lt;keylock hobtid="72057594562412544" dbid="5" objectname="ALL.dbo.myconstants" indexname="pk_myconstants" id="lock9466df00" mode="RangeS-U" associatedObjectId="72057594562412544"&gt;
     &lt;owner-list&gt;
      &lt;owner id="process28fc21868" mode="RangeS-S" /&gt;
     &lt;/owner-list&gt;
     &lt;waiter-list&gt;
      &lt;waiter id="process2b6e94cf8" mode="X" requestType="convert" /&gt;
     &lt;/waiter-list&gt;
    &lt;/keylock&gt;
   &lt;/resource-list&gt;
  &lt;/deadlock&gt;
  </code></pre>
  
  <p><strong>Additional</strong>
  Version:
  Microsoft SQL Server 2012 (SP3-CU2) (KB3137746) - 11.0.6523.0 (X64) 
      Mar  2 2016 21:29:16 
      Copyright (c) Microsoft Corporation
      Standard Edition (64-bit) on Windows NT 6.3  (Build 9600: ) (Hypervisor)</p>