Reduce chances of race conditions when processing deleted toots (#9815)
* Reduce chances of race conditions when processing deleted toots * Prevent race condition when processing deleted toots
This commit is contained in:
		
					parent
					
						
							
								5363c724fc
							
						
					
				
			
			
				commit
				
					
						a4f07bad95
					
				
			
		
					 2 changed files with 11 additions and 3 deletions
				
			
		|  | @ -21,11 +21,13 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity | |||
|   def delete_note | ||||
|     return if object_uri.nil? | ||||
| 
 | ||||
|     RedisLock.acquire(lock_options) do |_lock| | ||||
|       delete_later!(object_uri) | ||||
|     end | ||||
| 
 | ||||
|     @status   = Status.find_by(uri: object_uri, account: @account) | ||||
|     @status ||= Status.find_by(uri: @object['atomUri'], account: @account) if @object.is_a?(Hash) && @object['atomUri'].present? | ||||
| 
 | ||||
|     delete_later!(object_uri) | ||||
| 
 | ||||
|     return if @status.nil? | ||||
| 
 | ||||
|     if @status.public_visibility? || @status.unlisted_visibility? | ||||
|  | @ -68,4 +70,8 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity | |||
|   def payload | ||||
|     @payload ||= Oj.dump(@json) | ||||
|   end | ||||
| 
 | ||||
|   def lock_options | ||||
|     { redis: Redis.current, key: "create:#{object_uri}" } | ||||
|   end | ||||
| end | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue