Jarvis Stubblefield
12/16/2022, 3:59 PMMySQLdb.OperationalError: (1205, 'Lock wait timeout exceeded; try restarting transaction')
… any thoughts or ideas on what might be causing additional delay?Jarvis Stubblefield
12/16/2022, 4:02 PMJarvis Stubblefield
12/16/2022, 4:03 PM@flow
def update_and_alert_about_users_who_need_logs():
logger = get_run_logger()
# Update any users who need new auto logs.
transaction.set_autocommit(False)
num_updates = 0
num_last_log_alerts = 0
num_changes = 0
active = HREUser.active.all()
active.filter(Q(org__in=Organization.active.all()))
for user in active:
try:
if LivePerformance.maybe_update(user):
user.save()
num_updates += 1
num_changes += 1
if user.logs_needed_alert():
num_last_log_alerts += 1
num_changes += 1
except KeyboardInterrupt:
raise
except:
traceback.print_exc()
if num_changes > 1000:
<http://logger.info|logger.info>("Committing progress...")
num_changes = 0
transaction.commit()
<http://logger.info|logger.info>("Committing changes.")
transaction.commit()
<http://logger.info|logger.info>(f"{num_updates} users needed a score update.")
<http://logger.info|logger.info>(f"{num_last_log_alerts} users needed a last log alert.")
Jarvis Stubblefield
12/16/2022, 4:23 PMmysql> show full processlist;
+--------+------------+--------------------+-----------------+---------+------+----------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+------------+--------------------+-----------------+---------+------+----------+-----------------------+
| 884310 | xxxxxxxxxx | localhost | NULL | Sleep | 3 | | NULL |
| 890453 | xxxxxxxxxx | xxx.xx.xx.75:35920 | tenzinga_django | Sleep | 0 | | NULL |
| 894731 | xxxxxxxxxx | xxx.xx.xx.31:53302 | tenzinga_django | Sleep | 1771 | | NULL |
| 894732 | xxxxxxxxxx | xxx.xx.xx.31:53304 | tenzinga_django | Query | 0 | starting | show full processlist |
+--------+------------+--------------------+-----------------+---------+------+----------+-----------------------+
4 rows in set (0.00 sec)
Jarvis Stubblefield
12/16/2022, 4:43 PMshow engine innodb status;
output…Jarvis Stubblefield
12/16/2022, 4:43 PMJarvis Stubblefield
12/16/2022, 5:00 PM