fix: adjust sync probability and enable requestSync in DocumentSchema

- Reduced the background sync probability from 0.1% to 0.01% to minimize unnecessary sync attempts.
- Enabled the requestSync flag in the payload to ensure synchronization requests are properly handled.

These changes aim to optimize the background synchronization process within the DocumentSchema, enhancing performance and control over sync operations.
This commit is contained in:
2024-12-17 05:30:45 +07:00
parent d8b5abe1ed
commit 19059f0e19

View File

@@ -750,7 +750,7 @@ export class DocumentSchema extends PothosSchema {
} }
// Only perform background check with a very low probability // Only perform background check with a very low probability
const SYNC_PROBABILITY = 0.01; // 0.1% chance const SYNC_PROBABILITY = 0.001; // 0.1% chance
const SYNC_INTERVAL_MS = 15000; // 15 seconds minimum between syncs const SYNC_INTERVAL_MS = 15000; // 15 seconds minimum between syncs
const syncKey = `document:sync:${payload.documentId}:${payload.pageIndex}`; const syncKey = `document:sync:${payload.documentId}:${payload.pageIndex}`;
@@ -775,6 +775,8 @@ export class DocumentSchema extends PothosSchema {
// ctx // ctx
// ); // );
} }
payload.requestSync = true;
// biome-ignore lint/suspicious/noExplicitAny: error is any // biome-ignore lint/suspicious/noExplicitAny: error is any
} catch (error: any) { } catch (error: any) {
Logger.error("Background sync check failed", { Logger.error("Background sync check failed", {