You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/models/db
Earl Warren b748d62b46
Add slow SQL query warning (#27545)
- Databases are one of the most important parts of Forgejo, every
interaction uses the database in one way or another. Therefore, it is
important to maintain the database and recognize when the server is not
doing well with the database. There already is 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 9cf501f1af4cd870221cef6af489618785b71186)

---------

Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
11 months ago
..
install Implement FSFE REUSE for golang files (#21840) 2 years ago
paginator Move more functions to db.Find (#28419) 1 year ago
collation.go Recommend/convert to use case-sensitive collation for MySQL/MSSQL (#28662) 1 year ago
common.go Fix NuGet search endpoints (#25613) 1 year ago
consistency.go Implement FSFE REUSE for golang files (#21840) 2 years ago
context.go Refactor deletion (#28610) 1 year ago
context_committer_test.go Fix halfCommitter and WithTx (#22366) 2 years ago
context_test.go Always reuse transaction (#22362) 2 years ago
convert.go Recommend/convert to use case-sensitive collation for MySQL/MSSQL (#28662) 1 year ago
engine.go Add slow SQL query warning (#27545) 11 months ago
engine_test.go Rename `Sync2` -> `Sync` (#26479) 1 year ago
error.go Refactor deletion (#28610) 1 year ago
index.go Fix index generation parallelly failure (#25235) 2 years ago
index_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
iterate.go refactor: make db iterate context aware (#27710) 1 year ago
iterate_test.go Remove GetByBean method because sometimes it's danger when query condition parameter is zero and also introduce new generic methods (#28220) 1 year ago
list.go Fix joins in `db.Find(AndCount)` (#28978) 1 year ago
list_test.go Use db.Find instead of writing methods for every object (#28084) 1 year ago
log.go Replace `interface{}` with `any` (#25686) 2 years ago
main_test.go make writing main test easier (#27270) 1 year ago
name.go Implement FSFE REUSE for golang files (#21840) 2 years ago
search.go Split lfs size from repository size (#22900) 2 years ago
sequence.go Refactor `setting.Database.UseXXX` to methods (#23354) 2 years ago
sql_postgres_with_schema.go Fix .golangci.yml (#22868) 2 years ago