首页 > 社区问答列表 >mysql 死锁问题 TP3.23

  mysql 死锁问题 TP3.23

            $this->startTrans();//启用事务
            $tokenInfo = $this->where($wdata)->lock(true)->find();//锁行
            //过期更新并返回
            ...
            //不过期返回
            ...
            
 日记记录           
[ 2023-08-08T14:39:20+08:00 ] 127.0.0.1 /api.php?c=Login&a=getToken
NOTIC: [8] Undefined index: master D:\wwwroot\base\Core\Library\Think\Db\Driver.class.php 第 958 行.
ERR: 1213:Deadlock found when trying to get lock; try restarting transaction
 [ SQL语句 ] : SELECT * FROM `zzy_user_token` WHERE `token` = '58bd5f8dd24c82c0404d4d90a386b6c1' LIMIT 1   FOR UPDATE 
ERR: 1213:Deadlock found when trying to get lock; try restarting transaction
 [ SQL语句 ] : SELECT * FROM `zzy_user_token` WHERE `token` = '58bd5f8dd24c82c0404d4d90a386b6c1' LIMIT 1   FOR UPDATE 

[ 2023-08-08T14:39:20+08:00 ] 127.0.0.1 /api.php?c=Login&a=getToken
INFO: [ app_init ] --START--
INFO: Run Behavior\BuildLiteBehavior [ RunTime:0.000007s ]
INFO: [ app_init ] --END-- [ RunTime:0.000308s ]
INFO: [ app_begin ] --START--
INFO: Run Behavior\ReadHtmlCacheBehavior [ RunTime:0.000477s ]
INFO: [ app_begin ] --END-- [ RunTime:0.000502s ]
SQL: SHOW COLUMNS FROM `zzy_user_token` [ RunTime:0.0007s ]
NOTIC: [8] Undefined index: master D:\wwwroot\base\Core\Library\Think\Db\Driver.class.php 第 958 行.
SQL: SELECT * FROM `zzy_user_token` WHERE `token` = '58bd5f8dd24c82c0404d4d90a386b6c1' LIMIT 1   FOR UPDATE  [ RunTime:0.0003s ]
NOTIC: [2] Declaration of Common\Model\UserModel::_list($model, $map, $listRows = 20, $_order_sort = '') should be compatible with Common\Model\BaseModel::_list($model, $map, $listRows = '', $sortBy = '', $field = '*') D:\wwwroot\base\Web\Common\Model\UserModel.class.php 第 9 行.
SQL: SHOW COLUMNS FROM `zzy_user` [ RunTime:0.0008s ]
NOTIC: [8] Undefined index: master D:\wwwroot\base\Core\Library\Think\Db\Driver.class.php 第 958 行.
SQL: SELECT * FROM `zzy_user` WHERE `uid` = 1100 LIMIT 1   [ RunTime:0.0002s ]
NOTIC: [8] Undefined index: status_login_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: status_shop_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: status_withdraw_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: lv_name D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [2] Declaration of Common\Model\UserLevelModel::getList($map = Array) should be compatible with Common\Model\BaseModel::getList($map = Array, $listRows = 20, $_order_sort = '') D:\wwwroot\base\Web\Common\Model\UserLevelModel.class.php 第 186 行.
NOTIC: [2] Declaration of Common\Model\UserLevelModel::check($uid) should be compatible with Think\Model::check($value, $rule, $type = 'regex') D:\wwwroot\base\Web\Common\Model\UserLevelModel.class.php 第 186 行.
SQL: SHOW COLUMNS FROM `zzy_user_level` [ RunTime:0.0005s ]
NOTIC: [8] Undefined index: master D:\wwwroot\base\Core\Library\Think\Db\Driver.class.php 第 958 行.
SQL: SELECT * FROM `zzy_user_level` WHERE `status` = 1 ORDER BY id asc  [ RunTime:0.0001s ]
NOTIC: [8] Undefined index: status_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 626 行.
NOTIC: [8] Undefined index: status_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 626 行.
NOTIC: [8] Undefined index: status_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 626 行.
NOTIC: [8] Undefined index: status_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 626 行.
NOTIC: [8] Undefined index: status_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 626 行.
NOTIC: [8] Undefined index: group_name D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [2] Declaration of Common\Model\UserGroupModel::getList() should be compatible with Common\Model\BaseModel::getList($map = Array, $listRows = 20, $_order_sort = '') D:\wwwroot\base\Web\Common\Model\UserGroupModel.class.php 第 97 行.
SQL: SHOW COLUMNS FROM `zzy_user_group` [ RunTime:0.0005s ]
NOTIC: [8] Undefined index: id D:\wwwroot\base\Web\Common\Model\UserModel.class.php 第 133 行.
NOTIC: [8] Undefined index: reg_type_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: reg_time_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: login_time_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
NOTIC: [8] Undefined index: inv_code D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
SQL: SHOW COLUMNS FROM `zzy_user_info` [ RunTime:0.0006s ]
NOTIC: [8] Undefined index: master D:\wwwroot\base\Core\Library\Think\Db\Driver.class.php 第 958 行.
SQL: SELECT * FROM `zzy_user_info` WHERE `uid` = 1100 LIMIT 1   [ RunTime:0.0001s ]
NOTIC: [8] Undefined index: sex_text D:\wwwroot\base\Core\Library\Think\Model.class.php 第 827 行.
SQL: UPDATE `zzy_user_token` SET `cancel_time`='1691476790' WHERE `token` = '58bd5f8dd24c82c0404d4d90a386b6c1' [ RunTime:0.0004s ]
NOTIC: [8] Undefined variable: form D:\wwwroot\base\Web\Common\Model\UserTokenModel.class.php 第 287 行.
SQL: INSERT INTO `zzy_user_token` (`uid`,`form`,`edit_time`,`token`) VALUES ('1100','1','1691476760','0bc5b14567fd7d6a3cc06127ac218630') [ RunTime:0.0004s ]
NOTIC: [8] Undefined index: msg D:\wwwroot\base\Web\Api\Controller\LoginController.class.php 第 172 行.


照逻辑来说,读取这条数据后锁行,并发请求的等待执行(排队),执行完第二条获取新数据,第三条获取新数据

始终找不到死锁的原因...

vion77
vion77

无数据提示还没有回复,楼主喊你快去抢前排~~~我来回答