mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Fix database deadlock when update issue labels (#17649)
This fix updates issue labels one by one, and won't cause database deadlock. In future, we can use a batch API to update all changed labels by one request.
This commit is contained in:
		| @@ -332,20 +332,16 @@ export function initRepoIssueWipTitle() { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
| export function updateIssuesMeta(url, action, issueIds, elementId) { | export async function updateIssuesMeta(url, action, issueIds, elementId) { | ||||||
|   return new Promise((resolve, reject) => { |   return $.ajax({ | ||||||
|     $.ajax({ |     type: 'POST', | ||||||
|       type: 'POST', |     url, | ||||||
|       url, |     data: { | ||||||
|       data: { |       _csrf: csrfToken, | ||||||
|         _csrf: csrfToken, |       action, | ||||||
|         action, |       issue_ids: issueIds, | ||||||
|         issue_ids: issueIds, |       id: elementId, | ||||||
|         id: elementId, |     }, | ||||||
|       }, |  | ||||||
|       success: resolve, |  | ||||||
|       error: reject, |  | ||||||
|     }); |  | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -84,18 +84,18 @@ export function initRepoCommentForm() { | |||||||
|     $(`.${selector}`).dropdown('setting', 'onHide', () => { |     $(`.${selector}`).dropdown('setting', 'onHide', () => { | ||||||
|       hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var |       hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var | ||||||
|       if (hasUpdateAction) { |       if (hasUpdateAction) { | ||||||
|         const promises = []; |         // TODO: Add batch functionality and make this 1 network request. | ||||||
|         Object.keys(items).forEach((elementId) => { |         (async function() { | ||||||
|           const item = items[elementId]; |           for (const [elementId, item] of Object.entries(items)) { | ||||||
|           const promise = updateIssuesMeta( |             await updateIssuesMeta( | ||||||
|             item['update-url'], |               item['update-url'], | ||||||
|             item.action, |               item.action, | ||||||
|             item['issue-id'], |               item['issue-id'], | ||||||
|             elementId, |               elementId, | ||||||
|           ); |             ); | ||||||
|           promises.push(promise); |           } | ||||||
|         }); |           window.location.reload(); | ||||||
|         Promise.all(promises).then(() => window.location.reload()); |         })(); | ||||||
|       } |       } | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user