mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-09-17 10:15:51 +00:00
change block size, checkpoint after vacuum, disable auto-vacuum
This commit is contained in:
@@ -41,6 +41,7 @@ module Simplex.Messaging.Agent
|
||||
SubscriptionsInfo (..),
|
||||
getSMPAgentClient,
|
||||
disconnectAgentClient,
|
||||
disposeAgentClient,
|
||||
resumeAgentClient,
|
||||
withConnLock,
|
||||
createUser,
|
||||
@@ -179,6 +180,11 @@ disconnectAgentClient c@AgentClient {agentEnv = Env {ntfSupervisor = ns, xftpAge
|
||||
closeXFTPAgent xa
|
||||
logConnection c False
|
||||
|
||||
disposeAgentClient :: MonadUnliftIO m => AgentClient -> m ()
|
||||
disposeAgentClient c@AgentClient {agentEnv = Env {store}} = do
|
||||
disconnectAgentClient c
|
||||
liftIO $ closeSQLiteStore store
|
||||
|
||||
resumeAgentClient :: MonadIO m => AgentClient -> m ()
|
||||
resumeAgentClient c = atomically $ writeTVar (active c) True
|
||||
|
||||
|
||||
@@ -402,9 +402,10 @@ connectDB path key checkPageSize = do
|
||||
where
|
||||
prepare db = do
|
||||
unless (null key) . execSQL_ db $ "PRAGMA key = " <> sqlString key <> ";"
|
||||
when checkPageSize $ do
|
||||
pageSize :: Maybe Int <- maybeFirstRow fromOnly $ SQL.query_ (DB.conn db) "PRAGMA page_size;"
|
||||
when (pageSize == Just 16384) $ execSQL_ db
|
||||
when checkPageSize $ maybeFirstRow id (SQL.query_ (DB.conn db) "PRAGMA page_size;") >>= \case
|
||||
Nothing -> pure ()
|
||||
Just (Only (16384 :: Int)) -> pure ()
|
||||
Just _ -> execSQL_ db
|
||||
"PRAGMA wal_checkpoint(TRUNCATE);\n\
|
||||
\PRAGMA journal_mode = DELETE;\n\
|
||||
\PRAGMA page_size = 16384;\n\
|
||||
@@ -416,8 +417,7 @@ connectDB path key checkPageSize = do
|
||||
\PRAGMA busy_timeout = 100;\n\
|
||||
\PRAGMA foreign_keys = ON;\n\
|
||||
\-- PRAGMA trusted_schema = OFF;\n\
|
||||
\PRAGMA secure_delete = ON;\n\
|
||||
\PRAGMA auto_vacuum = FULL;"
|
||||
\PRAGMA secure_delete = ON;"
|
||||
|
||||
closeSQLiteStore :: SQLiteStore -> IO ()
|
||||
closeSQLiteStore st@SQLiteStore {dbClosed} =
|
||||
|
||||
@@ -121,7 +121,7 @@ getCurrent db = map toMigration <$> DB.query_ db "SELECT name, down FROM migrati
|
||||
run :: SQLiteStore -> MigrationsToRun -> IO ()
|
||||
run st = \case
|
||||
MTRUp [] -> pure ()
|
||||
MTRUp ms -> mapM_ runUp ms >> withConnection' st (`execSQL` "VACUUM;")
|
||||
MTRUp ms -> mapM_ runUp ms >> withConnection' st (`execSQL` "VACUUM; PRAGMA wal_checkpoint(TRUNCATE);")
|
||||
MTRDown ms -> mapM_ runDown $ reverse ms
|
||||
MTRNone -> pure ()
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user