Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jestがランダムに落ちる #10802

Open
syuilo opened this issue May 8, 2023 · 15 comments
Open

Jestがランダムに落ちる #10802

syuilo opened this issue May 8, 2023 · 15 comments
Labels
🐛Bug Unexpected behavior 🛠️Dev Development of Misskey itself packages/backend:test

Comments

@syuilo
Copy link
Member

syuilo commented May 8, 2023

解決した方に報奨金を進呈

@syuilo syuilo added 🐛Bug Unexpected behavior 🛠️Dev Development of Misskey itself packages/backend:test labels May 8, 2023
@tamaina
Copy link
Contributor

tamaina commented May 8, 2023

ん、どれ

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

@Nanashia
Copy link
Contributor

Nanashia commented May 8, 2023

    QueryFailedError: relation "muting" does not exist

(再現コード書けてないけど、)BullのRepeat JobとDBの初期化がタイミング的にぶつかると不味そう?

CheckExpiredMutingsProcessorService は5分毎に実行されます。

this.queueService.systemQueue.add('checkExpiredMutings', {
}, {
repeat: { cron: '*/5 * * * *' },
removeOnComplete: true,
});

一方でテスト環境ではPostgresはstartServer毎に中身を捨てて毎回migrationをすべて実行するようになっています。

synchronize: process.env.NODE_ENV === 'test',
dropSchema: process.env.NODE_ENV === 'test',
cache: !config.db.disableCache && process.env.NODE_ENV !== 'test' ? { // dbをcloseしても何故かredisのコネクションが内部的に残り続けるようで、テストの際に支障が出るため無効にする(キャッシュも含めてテストしたいため本当は有効にしたいが...)


類似パターンとして
https://github.com/misskey-dev/misskey/actions/runs/4915818443/jobs/8778777119

    QueryFailedError: relation "following" does not exist

みたいなのもあるけど、こっちは分針が55の時にぶつかると起きる感じ?

this.queueService.systemQueue.add('tickCharts', {
}, {
repeat: { cron: '55 * * * *' },
removeOnComplete: true,
});

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

あーーー

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

テスト中はそれらのキュー無効化してみるか

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

いや通常のテストではjobQueue起動しないようにすでになっている

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

どこで呼ばれてるんだ

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

あーAccount Moveで呼んでるな

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

これ呼ぶ必要あるのかしら

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

なさそう

@syuilo
Copy link
Member Author

syuilo commented May 8, 2023

あーいや

await sleep(1000 * 3); // wait for jobs to finish

がある

@syuilo syuilo closed this as completed in 5c54e12 May 8, 2023
@syuilo syuilo reopened this May 8, 2023
@tamaina
Copy link
Contributor

tamaina commented May 9, 2023

Account Moveはキューを多用する

@Nanashia
Copy link
Contributor

Nanashia commented May 9, 2023

https://github.com/misskey-dev/misskey/actions/runs/4923097917/jobs/8794536924

PASS test/e2e/api-visibility.ts (33.251 s, 740 MB heap size)
PASS test/e2e/move.ts (46.698 s, 850 MB heap size)   ← ★★★ AccountMoveのテストでjq起動
PASS test/e2e/2fa.ts (27.001 s, 808 MB heap size)
FAIL test/e2e/fetch-resource.ts (29.898 s, 898 MB heap size  ← ★別のテストがFAIL
  ● Webリソース › /@:user/pages/:page › はGETできる。(存在しないIDでも。)

    TypeORMError: Driver not Connected

      36 | 			.innerJoinAndSelect('muting.mutee', 'mutee')
      37 | 			.getMany();
    > 38 |
         | ^
      39 | 		if (expired.length > 0) {
      40 | 			await this.userMutingService.unmute(expired);
      41 | 		}

...
      at SelectQueryBuilder.getMany (../../node_modules/.pnpm/[email protected][email protected][email protected]/src/query-builder/SelectQueryBuilder.ts:1759:36)
      at CheckExpiredMutingsProcessorService.process (src/queue/processors/CheckExpiredMutingsProcessorService.ts:38:56)
      at Queue.<anonymous> (src/queue/SystemQueueProcessorsService.ts:43:96) ← ★★★ なぜかjqが生き残っている???
      at Queue.Object.<anonymous>.Queue.processJob (../../node_modules/.pnpm/[email protected]/node_modules/bull/lib/queue.js:1166:22) 

5c54e12 で jq.close()を呼ぶようになりましたが、このJobQueueの実体(queue:systemなどのBull.Queue)はどこからもclose()されていないので、結局停止できていない気がします。
setIntervalやRedisのようにonApplicationShutdownを使って破棄する必要があるかも?(手元で検証中)

@syuilo
Copy link
Member Author

syuilo commented May 10, 2023

onApplicationShutdownで停止するようにした

@syuilo
Copy link
Member Author

syuilo commented May 11, 2023

直ったかも?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛Bug Unexpected behavior 🛠️Dev Development of Misskey itself packages/backend:test
Projects
None yet
Development

No branches or pull requests

3 participants