Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Unify the polling interval used by issue detail page update and backup update
天舟828c3fc31932
diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vueindex 095d4abfd8..551b9df834 100644--- a/frontend/src/components/DatabaseBackupPanel.vue+++ b/frontend/src/components/DatabaseBackupPanel.vue@@ -80,6 +80,9 @@ import {BackupSetting,BackupSettingUpsert,Database,+ NORMAL_POLL_INTERVAL,+ POLL_JITTER,+ POST_CHANGE_POLL_INTERVAL,UNKNOWN_ID,} from "../types";import BackupTable from "../components/BackupTable.vue";@@ -108,9 +111,6 @@ export default {},setup(props, ctx) {const store = useStore();- const NORMAL_BACKUPS_POLL_INTERVAL = 10000;- // Add jitter to avoid timer from different clients converging to the same polling frequency.- const POLL_JITTER = 500;// For now, we hard code the backup time to a time between 0:00 AM ~ 6:00 AM on Sunday local time.const DEFAULT_BACKUP_HOUR = Math.floor(Math.random() * 7);@@ -218,7 +218,7 @@ export default {databaseId: props.database.id,newBackup: newBackup,});- pollBackups(NORMAL_BACKUPS_POLL_INTERVAL);+ pollBackups(POST_CHANGE_POLL_INTERVAL);};// pollBackups invalidates the current timer and schedule a new timer in <<interval>> microseconds@@ -238,10 +238,10 @@ export default {}}if (pending) {- pollBackups(Math.min(interval * 2, NORMAL_BACKUPS_POLL_INTERVAL));+ pollBackups(Math.min(interval * 2, NORMAL_POLL_INTERVAL));}});- }, Math.max(1000, Math.min(interval, NORMAL_BACKUPS_POLL_INTERVAL) + (Math.random() * 2 - 1) * POLL_JITTER));+ }, Math.max(1000, Math.min(interval, NORMAL_POLL_INTERVAL) + (Math.random() * 2 - 1) * POLL_JITTER));};const prepareBackupSetting = () => {diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 6a50812248..2d4885a1a3 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -31,6 +31,14 @@ export const ONBOARDING_ISSUE_ID = 101;// For text input, we do validation if there is no further keystroke after 1sexport const TEXT_VALIDATION_DELAY = 1000;+// Normally, we poll issue every 30s to fetch any update from the server side.+// If change occurs, then we will start the poll from 1s, 2s, 4s, 8s, 16s, 30s, 30s ... with jitter+// We do this because new update is more likely to happen after the initial change (e.g task gets new update after changing its status)+export const NORMAL_POLL_INTERVAL = 30000;+export const POST_CHANGE_POLL_INTERVAL = 1000;+// Add jitter to avoid timer from different clients converging to the same polling frequency.+export const POLL_JITTER = 5000;+// RowStatusexport type RowStatus = "NORMAL" | "ARCHIVED" | "PENDING_DELETE";diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vueindex 3b1f881b60..2970bc6a8c 100644--- a/frontend/src/views/IssueDetail.vue+++ b/frontend/src/views/IssueDetail.vue@@ -278,6 +278,9 @@ import {TaskCreate,TaskDatabaseCreatePayload,TaskGeneralPayload,+ NORMAL_POLL_INTERVAL,+ POLL_JITTER,+ POST_CHANGE_POLL_INTERVAL,} from "../types";import {defaulTemplate,@@ -287,14 +290,6 @@ import {IssueTemplate,} from "../plugins";-// Normally, we poll issue every 30s to fetch any update from the server side.-// When issue/task status changes we start the poll from 1s, 2s, 4s, 8s, 16s, 30s, 30s ... with jitter-// We do this because issue is more likely to change after we change the status (e.g task finishes running)-const NORMAL_ISSUE_POLL_INTERVAL = 30000;-const POST_STATUS_CHANGE_ISSUE_POLL_INTERVAL = 1000;-// Add jitter to avoid timer from different clients converging to the same polling frequency.-const POLL_JITTER = 5000;-interface LocalState {// Needs to maintain this state and set it to false manually after creating the issue.// router.push won't trigger the reload because new and existing issue shares@@ -447,8 +442,8 @@ export default {state.pollIssueTimer = setTimeout(() => {store.dispatch("issue/fetchIssueById", idFromSlug(props.issueSlug));- pollIssue(Math.min(interval * 2, NORMAL_ISSUE_POLL_INTERVAL));- }, Math.max(1000, Math.min(interval, NORMAL_ISSUE_POLL_INTERVAL) + (Math.random() * 2 - 1) * POLL_JITTER));+ pollIssue(Math.min(interval * 2, NORMAL_POLL_INTERVAL));+ }, Math.max(1000, Math.min(interval, NORMAL_POLL_INTERVAL) + (Math.random() * 2 - 1) * POLL_JITTER));};onMounted(() => {@@ -458,13 +453,13 @@ export default {// won't work.document.getElementById("issue-detail-top")!.scrollIntoView();if (!state.create) {- let interval = NORMAL_ISSUE_POLL_INTERVAL;+ let interval = NORMAL_POLL_INTERVAL;// If we just created the database create issue, we will poll fast since it should return result soon.if (issue.value.type == "bb.issue.database.create" &&Date.now() - (issue.value as Issue).updatedTs * 1000 < 5000) {- interval = POST_STATUS_CHANGE_ISSUE_POLL_INTERVAL;+ interval = POST_CHANGE_POLL_INTERVAL;}pollIssue(interval);}@@ -482,7 +477,7 @@ export default {const oldCreate = state.create;state.create = cur.toLowerCase() == "new";if (!state.create && oldCreate) {- pollIssue(NORMAL_ISSUE_POLL_INTERVAL);+ pollIssue(NORMAL_POLL_INTERVAL);}});@@ -601,7 +596,7 @@ export default {issueStatusPatch,}).then(() => {- pollIssue(POST_STATUS_CHANGE_ISSUE_POLL_INTERVAL);+ pollIssue(POST_CHANGE_POLL_INTERVAL);});};@@ -626,7 +621,7 @@ export default {taskStatusPatch,}).then(() => {- pollIssue(POST_STATUS_CHANGE_ISSUE_POLL_INTERVAL);+ pollIssue(POST_CHANGE_POLL_INTERVAL);});};@@ -641,8 +636,8 @@ export default {}).then((updatedIssue) => {// issue/patchIssue already fetches the new issue, so we schedule- // the next poll in NORMAL_ISSUE_POLL_INTERVAL- pollIssue(NORMAL_ISSUE_POLL_INTERVAL);+ // the next poll in NORMAL_POLL_INTERVAL+ pollIssue(NORMAL_POLL_INTERVAL);if (postUpdated) {postUpdated(updatedIssue);}