Skip to content

Commit a50e2e7

Browse files
authored
agent: disable saving stats (#1214)
* agent: disable stat saving * disable migration * schema * disable restore
1 parent 6a54a58 commit a50e2e7

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

src/Simplex/Messaging/Agent.hs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,14 @@ getSMPAgentClient_ clientId cfg initServers store backgroundMode =
210210
runAgentThreads c
211211
| backgroundMode = run c "subscriber" $ subscriber c
212212
| otherwise = do
213-
restoreServersStats c
213+
-- restoreServersStats c
214214
raceAny_
215215
[ run c "subscriber" $ subscriber c,
216216
run c "runNtfSupervisor" $ runNtfSupervisor c,
217-
run c "cleanupManager" $ cleanupManager c,
218-
run c "logServersStats" $ logServersStats c
217+
run c "cleanupManager" $ cleanupManager c
218+
-- run c "logServersStats" $ logServersStats c
219219
]
220-
`E.finally` saveServersStats c
220+
-- `E.finally` saveServersStats c
221221
run AgentClient {subQ, acThread} name a =
222222
a `E.catchAny` \e -> whenM (isJust <$> readTVarIO acThread) $ do
223223
logError $ "Agent thread " <> name <> " crashed: " <> tshow e
@@ -234,12 +234,13 @@ logServersStats c = do
234234

235235
saveServersStats :: AgentClient -> AM' ()
236236
saveServersStats c@AgentClient {subQ, smpServersStats, xftpServersStats} = do
237-
sss <- mapM (lift . getAgentSMPServerStats) =<< readTVarIO smpServersStats
238-
xss <- mapM (lift . getAgentXFTPServerStats) =<< readTVarIO xftpServersStats
239-
let stats = AgentPersistedServerStats {smpServersStats = sss, xftpServersStats = xss}
240-
tryAgentError' (withStore' c (`updateServersStats` stats)) >>= \case
241-
Left e -> atomically $ writeTBQueue subQ ("", "", AEvt SAEConn $ ERR $ INTERNAL $ show e)
242-
Right () -> pure ()
237+
-- sss <- mapM (lift . getAgentSMPServerStats) =<< readTVarIO smpServersStats
238+
-- xss <- mapM (lift . getAgentXFTPServerStats) =<< readTVarIO xftpServersStats
239+
-- let stats = AgentPersistedServerStats {smpServersStats = sss, xftpServersStats = xss}
240+
-- tryAgentError' (withStore' c (`updateServersStats` stats)) >>= \case
241+
-- Left e -> atomically $ writeTBQueue subQ ("", "", AEvt SAEConn $ ERR $ INTERNAL $ show e)
242+
-- Right () -> pure ()
243+
pure ()
243244

244245
restoreServersStats :: AgentClient -> AM' ()
245246
restoreServersStats c@AgentClient {smpServersStats, xftpServersStats, srvStatsStartedAt} = do

src/Simplex/Messaging/Agent/Store/SQLite/Migrations.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ schemaMigrations =
113113
("m20240124_file_redirect", m20240124_file_redirect, Just down_m20240124_file_redirect),
114114
("m20240223_connections_wait_delivery", m20240223_connections_wait_delivery, Just down_m20240223_connections_wait_delivery),
115115
("m20240225_ratchet_kem", m20240225_ratchet_kem, Just down_m20240225_ratchet_kem),
116-
("m20240417_rcv_files_approved_relays", m20240417_rcv_files_approved_relays, Just down_m20240417_rcv_files_approved_relays),
117-
("m20240518_servers_stats", m20240518_servers_stats, Just down_m20240518_servers_stats)
116+
("m20240417_rcv_files_approved_relays", m20240417_rcv_files_approved_relays, Just down_m20240417_rcv_files_approved_relays)
117+
-- ("m20240518_servers_stats", m20240518_servers_stats, Just down_m20240518_servers_stats)
118118
]
119119

120120
-- | The list of migrations in ascending order by date

src/Simplex/Messaging/Agent/Store/SQLite/Migrations/agent_schema.sql

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,6 @@ CREATE TABLE processed_ratchet_key_hashes(
394394
created_at TEXT NOT NULL DEFAULT(datetime('now')),
395395
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
396396
);
397-
CREATE TABLE servers_stats(
398-
servers_stats_id INTEGER PRIMARY KEY,
399-
servers_stats TEXT,
400-
started_at TEXT NOT NULL DEFAULT(datetime('now')),
401-
created_at TEXT NOT NULL DEFAULT(datetime('now')),
402-
updated_at TEXT NOT NULL DEFAULT(datetime('now'))
403-
);
404397
CREATE UNIQUE INDEX idx_rcv_queues_ntf ON rcv_queues(host, port, ntf_id);
405398
CREATE UNIQUE INDEX idx_rcv_queue_id ON rcv_queues(conn_id, rcv_queue_id);
406399
CREATE UNIQUE INDEX idx_snd_queue_id ON snd_queues(conn_id, snd_queue_id);

0 commit comments

Comments
 (0)