mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
lsof db on stuck transaction
This commit is contained in:
parent
d3c40a423e
commit
d686ce12b6
|
@ -32,6 +32,7 @@ from .util import (
|
||||||
absreal,
|
absreal,
|
||||||
atomic_move,
|
atomic_move,
|
||||||
djoin,
|
djoin,
|
||||||
|
db_ex_chk,
|
||||||
fsenc,
|
fsenc,
|
||||||
min_ex,
|
min_ex,
|
||||||
quotep,
|
quotep,
|
||||||
|
@ -645,7 +646,7 @@ class Up2k(object):
|
||||||
with self.mutex:
|
with self.mutex:
|
||||||
reg = self.register_vpath(top, vol.flags)
|
reg = self.register_vpath(top, vol.flags)
|
||||||
assert reg and self.pp
|
assert reg and self.pp
|
||||||
cur, _ = reg
|
cur, db_path = reg
|
||||||
|
|
||||||
db = Dbw(cur, 0, time.time())
|
db = Dbw(cur, 0, time.time())
|
||||||
self.pp.n = next(db.c.execute("select count(w) from up"))[0]
|
self.pp.n = next(db.c.execute("select count(w) from up"))[0]
|
||||||
|
@ -665,7 +666,8 @@ class Up2k(object):
|
||||||
try:
|
try:
|
||||||
n_add = self._build_dir(db, top, set(excl), top, rtop, rei, reh, [])
|
n_add = self._build_dir(db, top, set(excl), top, rtop, rei, reh, [])
|
||||||
n_rm = self._drop_lost(db.c, top)
|
n_rm = self._drop_lost(db.c, top)
|
||||||
except:
|
except Exception as ex:
|
||||||
|
db_ex_chk(self.log, ex, db_path)
|
||||||
t = "failed to index volume [{}]:\n{}"
|
t = "failed to index volume [{}]:\n{}"
|
||||||
self.log(t.format(top, min_ex()), c=1)
|
self.log(t.format(top, min_ex()), c=1)
|
||||||
|
|
||||||
|
@ -1946,9 +1948,13 @@ class Up2k(object):
|
||||||
if not cur:
|
if not cur:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.db_rm(cur, rd, fn)
|
try:
|
||||||
self.db_add(cur, wark, rd, fn, lmod, sz, ip, at)
|
self.db_rm(cur, rd, fn)
|
||||||
cur.connection.commit()
|
self.db_add(cur, wark, rd, fn, lmod, sz, ip, at)
|
||||||
|
cur.connection.commit()
|
||||||
|
except Exception as ex:
|
||||||
|
db_ex_chk(self.log, ex, self.register_vpath(ptop, {})[1])
|
||||||
|
raise
|
||||||
|
|
||||||
if "e2t" in self.flags[ptop]:
|
if "e2t" in self.flags[ptop]:
|
||||||
self.tagq.put((ptop, wark, rd, fn))
|
self.tagq.put((ptop, wark, rd, fn))
|
||||||
|
|
|
@ -1207,6 +1207,20 @@ def s3dec(rd: str, fn: str) -> tuple[str, str]:
|
||||||
return ret[0], ret[1]
|
return ret[0], ret[1]
|
||||||
|
|
||||||
|
|
||||||
|
def db_ex_chk(log: "NamedLogger", ex: Exception, db_path: str) -> None:
|
||||||
|
if str(ex) != "database is locked":
|
||||||
|
return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
rc, so, se = runcmd([b"lsof", fsenc(db_path)])
|
||||||
|
zs = (so.strip() + "\n" + se.strip()).strip()
|
||||||
|
log("lsof {} = {}\n{}".format(db_path, rc, zs), 3)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def atomic_move(usrc: str, udst: str) -> None:
|
def atomic_move(usrc: str, udst: str) -> None:
|
||||||
src = fsenc(usrc)
|
src = fsenc(usrc)
|
||||||
dst = fsenc(udst)
|
dst = fsenc(udst)
|
||||||
|
|
Loading…
Reference in a new issue