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.
tokarchuk/v1.17
wxiaoguang 3 years ago committed by GitHub
parent 3a60e0ad89
commit 6292603215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      web_src/js/features/repo-issue.js
  2. 14
      web_src/js/features/repo-legacy.js

@ -332,9 +332,8 @@ export function initRepoIssueWipTitle() {
});
}
export function updateIssuesMeta(url, action, issueIds, elementId) {
return new Promise((resolve, reject) => {
$.ajax({
export async function updateIssuesMeta(url, action, issueIds, elementId) {
return $.ajax({
type: 'POST',
url,
data: {
@ -343,9 +342,6 @@ export function updateIssuesMeta(url, action, issueIds, elementId) {
issue_ids: issueIds,
id: elementId,
},
success: resolve,
error: reject,
});
});
}

@ -84,18 +84,18 @@ export function initRepoCommentForm() {
$(`.${selector}`).dropdown('setting', 'onHide', () => {
hasUpdateAction = $listMenu.data('action') === 'update'; // Update the var
if (hasUpdateAction) {
const promises = [];
Object.keys(items).forEach((elementId) => {
const item = items[elementId];
const promise = updateIssuesMeta(
// TODO: Add batch functionality and make this 1 network request.
(async function() {
for (const [elementId, item] of Object.entries(items)) {
await updateIssuesMeta(
item['update-url'],
item.action,
item['issue-id'],
elementId,
);
promises.push(promise);
});
Promise.all(promises).then(() => window.location.reload());
}
window.location.reload();
})();
}
});

Loading…
Cancel
Save