Software /
code /
prosody
Annotate
util/gc.lua @ 13633:6b84d11aa09b
mod_storage_sql: Detect SQLite3 without UPSERT (or SQLCipher 3.x)
SQLCipher v3.4.1 (the version in Debian 12) is based on SQLite3 v3.15.2,
while UPSERT support was introduced in SQLite3 v3.24.0
This check was not needed before because we v3.24.0 has not been in a
version of Debian we support for a long, long time.
Note however that SQLCipher databases are not compatible across major
versions, upgrading from v3.x to v4.x requires executing a migration.
Attempts at making `prosodyctl mod_storage_sql upgrade` perform such a
migration has not been successful.
Executing the following in the `sqlcipher` tool should do the migration:
PRAGMA key = '<key material>';
PRAGMA cipher_migrate;
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 23 Jan 2025 19:33:05 +0100 |
parent | 12975:d10957394a3c |
rev | line source |
---|---|
12975
d10957394a3c
util: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
11431
diff
changeset
|
1 local set = require "prosody.util.set"; |
10933
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local known_options = { |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 incremental = set.new { "mode", "threshold", "speed", "step_size" }; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 generational = set.new { "mode", "minor_threshold", "major_threshold" }; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 }; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
11431
4874b54af344
util.gc: Fix check for Lua 5.4
Kim Alvefur <zash@zash.se>
parents:
10935
diff
changeset
|
8 if _VERSION ~= "Lua 5.4" then |
10933
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 known_options.generational = nil; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 known_options.incremental:remove("step_size"); |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local function configure(user, defaults) |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local mode = user.mode or defaults.mode or "incremental"; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 if not known_options[mode] then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 return nil, "GC mode not supported on ".._VERSION..": "..mode; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 for k, v in pairs(user) do |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 if not known_options[mode]:contains(k) then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 return nil, "Unknown GC parameter: "..k; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 elseif k ~= "mode" and type(v) ~= "number" then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 return nil, "parameter '"..k.."' should be a number"; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 if mode == "incremental" then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 if _VERSION == "Lua 5.4" then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 collectgarbage(mode, |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 user.threshold or defaults.threshold, |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 user.speed or defaults.speed, |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 user.step_size or defaults.step_size |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 ); |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 else |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 collectgarbage("setpause", user.threshold or defaults.threshold); |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 collectgarbage("setstepmul", user.speed or defaults.speed); |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 elseif mode == "generational" then |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 collectgarbage(mode, |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 user.minor_threshold or defaults.minor_threshold, |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 user.major_threshold or defaults.major_threshold |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 ); |
10935
2d57c49bfa12
util.gc: Linter fixes [luacheck]
Matthew Wild <mwild1@gmail.com>
parents:
10933
diff
changeset
|
43 end |
10933
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 return true; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 end |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 return { |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 configure = configure; |
f59bc81245b3
util.gc: New module for configuring the Lua garbage collector
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 }; |