mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
fix(server): same identify across pods (#9428)
This commit is contained in:
@@ -14,6 +14,7 @@ export const MUTEX_WAIT = 100;
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class Mutex {
|
export class Mutex {
|
||||||
protected logger = new Logger(Mutex.name);
|
protected logger = new Logger(Mutex.name);
|
||||||
|
private readonly clusterIdentifier = `cluster:${randomUUID()}`;
|
||||||
|
|
||||||
constructor(protected readonly locker: Locker) {}
|
constructor(protected readonly locker: Locker) {}
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ export class Mutex {
|
|||||||
* @param key resource key
|
* @param key resource key
|
||||||
* @returns LockGuard
|
* @returns LockGuard
|
||||||
*/
|
*/
|
||||||
async acquire(key: string, owner: string = 'global') {
|
async acquire(key: string, owner: string = this.clusterIdentifier) {
|
||||||
try {
|
try {
|
||||||
return await retryable(
|
return await retryable(
|
||||||
() => this.locker.lock(owner, key),
|
() => this.locker.lock(owner, key),
|
||||||
|
|||||||
Reference in New Issue
Block a user