mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	thumbnail: Set a stable ordering on ImageAttachment rows for locking.
Failure to have a stable ordering can lead to deadlocks.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							5e084a2128
						
					
				
				
					commit
					ef21dd9b99
				
			@@ -347,7 +347,9 @@ def get_user_upload_previews(
 | 
			
		||||
 | 
			
		||||
    upload_preview_data: dict[str, MarkdownImageMetadata] = {}
 | 
			
		||||
 | 
			
		||||
    image_attachments = ImageAttachment.objects.filter(realm_id=realm_id, path_id__in=path_ids)
 | 
			
		||||
    image_attachments = ImageAttachment.objects.filter(
 | 
			
		||||
        realm_id=realm_id, path_id__in=path_ids
 | 
			
		||||
    ).order_by("id")
 | 
			
		||||
    if lock:
 | 
			
		||||
        image_attachments = image_attachments.select_for_update()
 | 
			
		||||
    for image_attachment in image_attachments:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user