fix(backend): avoid deadlock when deleting account ()

This commit is contained in:
zyoshoka 2025-06-04 19:14:11 +09:00 committed by GitHub
parent b55cc03621
commit 65ba33867b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions
CHANGELOG.md
packages/backend
src/core
test-federation/test

View File

@ -15,6 +15,7 @@
### Server ### Server
- Feat: 全てのチャットメッセージを既読にするAPIを追加(chat/read-all) - Feat: 全てのチャットメッセージを既読にするAPIを追加(chat/read-all)
- Fix: アカウント削除が正常に行われないことがあった問題を修正
## 2025.6.0 ## 2025.6.0

View File

@ -803,14 +803,14 @@ export class DriveService {
await Promise.all(promises); await Promise.all(promises);
} }
this.deletePostProcess(file, isExpired, deleter); await this.deletePostProcess(file, isExpired, deleter);
} }
@bindThis @bindThis
private async deletePostProcess(file: MiDriveFile, isExpired = false, deleter?: MiUser) { private async deletePostProcess(file: MiDriveFile, isExpired = false, deleter?: MiUser) {
// リモートファイル期限切れ削除後は直リンクにする // リモートファイル期限切れ削除後は直リンクにする
if (isExpired && file.userHost !== null && file.uri != null) { if (isExpired && file.userHost !== null && file.uri != null) {
this.driveFilesRepository.update(file.id, { await this.driveFilesRepository.update(file.id, {
isLink: true, isLink: true,
url: file.uri, url: file.uri,
thumbnailUrl: null, thumbnailUrl: null,
@ -822,7 +822,7 @@ export class DriveService {
webpublicAccessKey: 'webpublic-' + randomUUID(), webpublicAccessKey: 'webpublic-' + randomUUID(),
}); });
} else { } else {
this.driveFilesRepository.delete(file.id); await this.driveFilesRepository.delete(file.id);
} }
this.driveChart.update(file, false); this.driveChart.update(file, false);

View File

@ -380,9 +380,7 @@ describe('User', () => {
strictEqual(followers.length, 1); // followed by Bob strictEqual(followers.length, 1); // followed by Bob
await alice.client.request('i/delete-account', { password: alice.password }); await alice.client.request('i/delete-account', { password: alice.password });
// NOTE: user deletion query is slow await sleep();
// FIXME: ensure user is removed successfully
await sleep(10000);
const following = await bob.client.request('users/following', { userId: bob.id }); const following = await bob.client.request('users/following', { userId: bob.id });
strictEqual(following.length, 0); // no following relation strictEqual(following.length, 0); // no following relation
@ -480,9 +478,7 @@ describe('User', () => {
strictEqual(followers.length, 1); // followed by Bob strictEqual(followers.length, 1); // followed by Bob
await aAdmin.client.request('admin/suspend-user', { userId: alice.id }); await aAdmin.client.request('admin/suspend-user', { userId: alice.id });
// NOTE: user deletion query is slow await sleep();
// FIXME: ensure user is removed successfully
await sleep(10000);
const following = await bob.client.request('users/following', { userId: bob.id }); const following = await bob.client.request('users/following', { userId: bob.id });
strictEqual(following.length, 0); // no following relation strictEqual(following.length, 0); // no following relation