rtutil: Fix crash when multiple RTLinkCaches race.
This was most likely to happen with multiple bean-checks running in parallel: they would both see a new RT URL, fetch it, and try to insert it into the cache. That's not a problem as long as they're both inserting the same URL, so catch that exception.
This commit is contained in:
parent
dc2e2d200d
commit
0e52f11a58
1 changed files with 10 additions and 4 deletions
|
@ -171,10 +171,16 @@ class RTLinkCache(_LinkCache):
|
|||
self._nourls.add(key)
|
||||
else:
|
||||
ticket_id, attachment_id = key
|
||||
self._db.execute(
|
||||
'INSERT INTO RTLinkCache VALUES(?, ?, ?)',
|
||||
(ticket_id, attachment_id, value),
|
||||
)
|
||||
try:
|
||||
self._db.execute(
|
||||
'INSERT INTO RTLinkCache VALUES(?, ?, ?)',
|
||||
(ticket_id, attachment_id, value),
|
||||
)
|
||||
except sqlite3.IntegrityError:
|
||||
# Another instance might've inserted the URL before we did.
|
||||
# That's fine as long as it's the same URL, which it should be.
|
||||
if value != self.get(key):
|
||||
raise
|
||||
|
||||
def __delitem__(self, key: TicketAttachmentIds) -> None:
|
||||
raise NotImplementedError("RTLinkCache.__delitem__")
|
||||
|
|
Loading…
Reference in a new issue