在数据库中检测到发生死锁。insert   aaa (a,b,c) select a,b,c from bb where b in(select d from  dd)
and sendFlag=0 and (sendTime="" or sendTime is null or sendTime< now() ) and  id between  NAME_CONST('t_minid',NULL) and  NAME_CONST('t_maxid',42447)   ;

解决方案 »

  1.   

    insert  into aaa (a,b,c) 
    select a,b,c from bb 
    where b in(select d from  dd)
    and sendFlag=0 
    and (sendTime="" or sendTime is null or sendTime< now() ) 
    and  id between  NAME_CONST('t_minid',NULL) and  NAME_CONST('t_maxid',42447)   ;
    这可以考虑下 if(sendTime is null,0,sendTime)>=Now()
      

  2.   

    insert   aaa (a,b,c) 
    select a,b,c from bb,dd where b=d
    and sendFlag=0 and (sendTime="" or sendTime is null or sendTime< now() ) and  id between  NAME_CONST('t_minid',NULL)
    and  NAME_CONST('t_maxid',42447)  
      

  3.   

    执行show innodb status看看引起死锁的语句