Patch #25590

prevent deadlocks in attachment deduplication

Added by Jens Krämer 6 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:HighDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Attachments
Target version:-

Description

At Planio we encountered occasional deadlocks caused by the inner lock statement on the query selecting a potentially already existing identical attachment. Running the query without lock first and locking the found record second solved the problem for us.

To account for the possible failure of the inner lock (i.e. when existing was found but cannot be locked) this patch also adds a rescue clause that silently ignores such errors. Deduplication did not happen in this case either because the duplicate was removed (then a retry would be useless) or the database aborted the transaction (deadlock or waited too long for the lock, a retry might work but I'm not sure it's worth it).

0001-prevent-deadlocks-by-only-locking-the-exact-records-.patch Magnifier (2.54 KB) Jens Krämer, 2017-04-12 03:51


Related issues

Blocks Redmine - Patch #25215: Re-use existing identical disk files for new attachments Closed

Associated revisions

Revision 16541
Added by Jean-Philippe Lang 6 months ago

Prevent deadlocks by only locking the exact records we need to have locked (#25590).

Patch by Jens Kraemer.

History

#1 Updated by Go MAEDA 6 months ago

  • Related to Patch #25215: Re-use existing identical disk files for new attachments added

#2 Updated by Go MAEDA 6 months ago

  • Related to deleted (Patch #25215: Re-use existing identical disk files for new attachments)

#3 Updated by Go MAEDA 6 months ago

  • Blocks Patch #25215: Re-use existing identical disk files for new attachments added

#4 Updated by Go MAEDA 6 months ago

I reopened #25215. Thank you for sharing the patch.

#5 Updated by Jean-Philippe Lang 6 months ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed.

Also available in: Atom PDF