forgejo/modules
Gusted 0d6b934eba
[GITEA] Add slow SQL query warning
- Databases are one of the most important parts of Forgejo, every
interaction with Forgejo uses the database in one way or another.
Therefore, it is important to maintain the database and recognize when
Forgejo is not doing well with the database. Forgejo already has the
option to log *every* SQL query along with its execution time, but
monitoring becomes impractical for larger instances and takes up
unnecessary storage in the logs.
- Add a QoL enhancement that allows instance administrators to specify a
threshold value beyond which query execution time is logged as a warning
in the xorm logger. The default value is a conservative five seconds to
avoid this becoming a source of spam in the logs.
- The use case for this patch is that with an instance the size of Codeberg, monitoring SQL logs is not very fruitful and most of them are uninteresting. Recently, in the context of persistent deadlock issues (https://codeberg.org/forgejo/forgejo/issues/220), I have noticed that certain queries hold locks on tables like comment and issue for several seconds. This patch helps to identify which queries these are and when they happen.
- Added unit test.

(cherry picked from commit 24bbe7886f)
(cherry picked from commit 6e29145b3c)
(cherry picked from commit 63731e3071)
(cherry picked from commit 3ce1a09736)
(cherry picked from commit a64426907d)
(cherry picked from commit 4b19215691)
(cherry picked from commit e635674435)
(cherry picked from commit 9cf501f1af)
2023-10-09 20:25:24 +02:00
..
actions [CI] Search .forgejo/workflows first 2023-10-09 18:25:28 +02:00
activitypub
analyze
assetfs
auth [SECURITY] default to pbkdf2 with 320,000 iterations 2023-10-09 19:11:02 +02:00
avatar
base
cache
charset
container
context
contexttest
csv
doctor
emoji
eventsource
generate
git
gitgraph
graceful
hcaptcha
highlight
hostmatcher
html
httpcache
httplib
indexer
issue/template
json
label
lfs
log
markup
mcaptcha
metrics
migration
nosql
options
packages
paginator
pprof
private
process
proxy
proxyprotocol
public
queue
recaptcha
references
regexplru
repository
secret
session
setting [GITEA] Add slow SQL query warning 2023-10-09 20:25:24 +02:00
sitemap
ssh
storage [CI] Forgejo Actions based CI for PR & branches 2023-10-09 18:25:28 +02:00
structs [v1.22] [FEAT] allow setting the update date on issues and comments 2023-10-09 19:11:03 +02:00
svg
sync
system
templates
test
testlogger
timeutil
translation
turnstile
typesniffer
updatechecker
upload
uri
user
util
validation [GITEA] add option for banning dots in usernames 2023-10-09 20:25:23 +02:00
web [GITEA] add option for banning dots in usernames 2023-10-09 20:25:23 +02:00
webhook