在尝试从表中删除时,我有时会 Lock wait timeout exceeded
错误。当许多人 .populate
命令(带 reserve_jobs=True
)正在并行运行。删除这些作业(中止它们的执行)并重新启动不会立即起作用,但会在几分钟后起作用。你知道那里发生了什么吗?delete命令本身不应触及当前正在处理的数据集。
InternalError Traceback (most recent call last)
<ipython-input-16-c52a52b02f79> in <module>()
----> 1 MakeDatasetsSessions.populate()
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\datajoint\autopopulate.py in populate(self, suppress_errors, reserve_jobs, order, limit, max_calls, display_progress, *restrictions)
135 call_count += 1
136 try:
--> 137 make(dict(key))
138 except (KeyboardInterrupt, SystemExit, Exception) as error:
139 try:
c:\work\python\dj-moser-imaging\dj_schemas\preprocess.py in make(self, key)
470 dataset_to_delete = (Dataset * Session.Data & 'session_name="{}"'.format(session_dict['session_name'])\
471 & 'datasettype="{}"'.format(datasettype)).fetch1('dataset_name')
--> 472 (Dataset & 'dataset_name = "{}"'.format(dataset_to_delete)).delete()
473 except dj.DataJointError:
474 logger.error('Session {} for animal {}: Tried to delete datasets after mismatch was detected, but could not proceed. '.format(\
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\datajoint\base_relation.py in delete(self, verbose)
358 try:
359 for r in reversed(list(delete_list.values())):
--> 360 count = r.delete_quick(get_count=True)
361 total += count
362 if (verbose or safe) and count:
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\datajoint\base_relation.py in delete_quick(self, get_count)
296 """
297 query = 'DELETE FROM ' + self.full_table_name + self.where_clause
--> 298 self.connection.query(query)
299 count = self.connection.query("SELECT ROW_COUNT()").fetchone()[0] if get_count else None
300 self._log(query[:255])
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\datajoint\connection.py in query(self, query, args, as_dict, suppress_warnings)
131 # suppress all warnings arising from underlying SQL library
132 warnings.simplefilter("ignore")
--> 133 cur.execute(query, args)
134
135 except err.OperationalError as e:
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\cursors.py in execute(self, query, args)
168 query = self.mogrify(query, args)
169
--> 170 result = self._query(query)
171 self._executed = query
172 return result
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\cursors.py in _query(self, q)
326 self._last_executed = q
327 self._clear_result()
--> 328 conn.query(q)
329 self._do_get_result()
330 return self.rowcount
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\connections.py in query(self, sql, unbuffered)
514 sql = sql.encode(self.encoding, 'surrogateescape')
515 self._execute_command(COMMAND.COM_QUERY, sql)
--> 516 self._affected_rows = self._read_query_result(unbuffered=unbuffered)
517 return self._affected_rows
518
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\connections.py in _read_query_result(self, unbuffered)
725 else:
726 result = MySQLResult(self)
--> 727 result.read()
728 self._result = result
729 if result.server_status is not None:
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\connections.py in read(self)
1064 def read(self):
1065 try:
-> 1066 first_packet = self.connection._read_packet()
1067
1068 if first_packet.is_ok_packet():
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\connections.py in _read_packet(self, packet_type)
681
682 packet = packet_type(buff, self.encoding)
--> 683 packet.check_error()
684 return packet
685
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\protocol.py in check_error(self)
218 errno = self.read_uint16()
219 if DEBUG: print("errno =", errno)
--> 220 err.raise_mysql_exception(self._data)
221
222 def dump(self):
~\AppData\Local\conda\conda\envs\analysis\lib\site-packages\pymysql\err.py in raise_mysql_exception(data)
107 errval = data[3:].decode('utf-8', 'replace')
108 errorclass = error_map.get(errno, InternalError)
--> 109 raise errorclass(errno, errval)
InternalError: (1205, 'Lock wait timeout exceeded; try restarting transaction')
1条答案
按热度按时间ewm0tg9j1#
在常规的datajoint使用中很少会发生超时。如果出现这种情况,我们需要彻底了解问题,并提出建议,以帮助避免它们。
在您的示例中,makedatasetssessions的make方法似乎试图删除某些内容。从populate调用中删除不是标准做法,我们需要理解(a)为什么需要删除,以及(b)为什么这个特定的删除导致超时。
为了理解这一点,请您发布make方法和erd的代码,其中包括makedatasetssessions和从中删除的表?