fetchInstanceMetadataの処理中にサーバーが強制終了された場合Lockが永遠に解除されない問題を修正 (MisskeyIO#191)
This commit is contained in:
parent
26ccb2c174
commit
e109334c59
|
@ -52,13 +52,13 @@ export class FetchInstanceMetadataService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async tryLock(host: string): Promise<boolean> {
|
public async tryLock(host: string): Promise<boolean> {
|
||||||
const mutex = await this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '1', 'GET');
|
const mutex = await this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '1', 'EX', 60 * 5, 'NX', 'GET');
|
||||||
return mutex !== '1';
|
return mutex !== '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public unlock(host: string): Promise<'OK'> {
|
public unlock(host: string): Promise<number> {
|
||||||
return this.redisClient.set(`fetchInstanceMetadata:mutex:${host}`, '0');
|
return this.redisClient.del(`fetchInstanceMetadata:mutex:${host}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Reference in New Issue