diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm
index 8e02faa3834..48e2baac6e5 100644
--- a/code/__HELPERS/_logging.dm
+++ b/code/__HELPERS/_logging.dm
@@ -128,7 +128,7 @@
/proc/log_qdel(text)
WRITE_LOG(GLOB.world_qdel_log, "QDEL: [text]")
-/proc/log_qdl(text)
+/proc/log_query_debug(text)
WRITE_LOG(GLOB.query_debug_log, "SQL: [text]")
/* Log to both DD and the logfile. */
diff --git a/code/controllers/configuration/entries/dbconfig.dm b/code/controllers/configuration/entries/dbconfig.dm
index c9dbdb4f542..1eb1186a8b7 100644
--- a/code/controllers/configuration/entries/dbconfig.dm
+++ b/code/controllers/configuration/entries/dbconfig.dm
@@ -4,7 +4,7 @@
/datum/config_entry/string/address
config_entry_value = "localhost"
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
-
+
/datum/config_entry/number/port
config_entry_value = 3306
min_val = 0
@@ -24,3 +24,8 @@
/datum/config_entry/string/feedback_tableprefix
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
+
+/datum/config_entry/number/query_debug_log_timeout
+ config_entry_value = 70
+ min_val = 1
+ protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
diff --git a/code/controllers/subsystem/dbcore.dm b/code/controllers/subsystem/dbcore.dm
index c3e8fb2f07d..7bc33c691a1 100644
--- a/code/controllers/subsystem/dbcore.dm
+++ b/code/controllers/subsystem/dbcore.dm
@@ -231,20 +231,24 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
to_chat(usr, "A SQL error occurred during this operation, check the server logs.")
/datum/DBQuery/proc/Execute(sql_query = sql, cursor_handler = default_cursor, log_error = TRUE)
- log_qdl("Query execution started at [SQLtime()] | [REALTIMEOFDAY]")
- var/stime = REALTIMEOFDAY
- log_qdl("Query used: [sql]")
+ var/start_time
+ var/timeout = CONFIG_GET(number/query_debug_log_timeout)
+ if(timeout)
+ log_query_debug("Query execution started at [SQLtime()] | [REALTIMEOFDAY]")
+ start_time = REALTIMEOFDAY
+ log_query_debug("Query used: [sql]")
Close()
. = _dm_db_execute(_db_query, sql_query, db_connection._db_con, cursor_handler, null)
if(!. && log_error)
log_sql("[ErrorMsg()] | Query used: [sql]")
- log_qdl("Query execution ended at [SQLtime()] | [REALTIMEOFDAY]")
- if((REALTIMEOFDAY - stime) > 70)
- log_qdl("Possible query overrun detected.")
- bother_admins()
+ log_query_debug("Query execution ended at [SQLtime()] | [REALTIMEOFDAY]")
+ if(timeout)
+ if((REALTIMEOFDAY - start_time) > timeout)
+ log_query_debug("Possible slow query timeout detected.")
+ slow_query_check()
-/proc/bother_admins()
- message_admins("HEY! A database query may have overrun. Did the server just hang? \[YES\]|\[NO\]")
+/datum/DBQuery/proc/slow_query_check()
+ message_admins("HEY! A database query may have timed out. Did the server just hang? \[YES\]|\[NO\]")
/datum/DBQuery/proc/NextRow()
return _dm_db_next_row(_db_query,item,conversions)
diff --git a/code/game/world.dm b/code/game/world.dm
index f950efc2c98..407a9be9a09 100644
--- a/code/game/world.dm
+++ b/code/game/world.dm
@@ -92,7 +92,7 @@ GLOBAL_PROTECT(security_mode)
GLOB.sql_error_log = "[GLOB.log_directory]/sql.log"
GLOB.world_qdel_log = "[GLOB.log_directory]/qdel.log"
GLOB.world_runtime_log = "[GLOB.log_directory]/runtime.log"
- GLOB.query_debug_log = "[GLOB.log_directory]/qdl.log"
+ GLOB.query_debug_log = "[GLOB.log_directory]/query_debug.log"
#ifdef UNIT_TESTS
GLOB.test_log = file("[GLOB.log_directory]/tests.log")
diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm
index c0be09ac5b7..d255c95d691 100644
--- a/code/modules/admin/topic.dm
+++ b/code/modules/admin/topic.dm
@@ -2464,15 +2464,15 @@
else if(href_list["slowquery"])
if(!check_rights(R_ADMIN))
return
- var/a = href_list["slowquery"]
- if(a == "yes")
- log_qdl("[usr.key] | reported hang")
- if(alert(usr, "Had you just press any admin buttons?", "Query hang report", "Yes", "No") == "Yes")
- var/s = input(usr,"What were you just doing?","Query hang report") as null|text
- if(s)
- log_qdl("[usr.key] | [s]")
- else if(a == "no")
- log_qdl("[usr.key] | reported no hang")
+ var/answer = href_list["slowquery"]
+ if(answer == "yes")
+ log_query_debug("[usr.key] | Reported a server hang")
+ if(alert(usr, "Had you just press any admin buttons?", "Query server hang report", "Yes", "No") == "Yes")
+ var/response = input(usr,"What were you just doing?","Query server hang report") as null|text
+ if(response)
+ log_query_debug("[usr.key] | [response]")
+ else if(answer == "no")
+ log_query_debug("[usr.key] | Reported no server hang")
/datum/admins/proc/HandleCMode()
if(!check_rights(R_ADMIN))
diff --git a/config/dbconfig.txt b/config/dbconfig.txt
index 146de44b352..cbbc839bb9c 100644
--- a/config/dbconfig.txt
+++ b/config/dbconfig.txt
@@ -18,7 +18,7 @@ FEEDBACK_DATABASE feedback
## Prefix to be added to the name of every table, older databases will require this be set to erro_
## Note, this does not change the table names in the database, you will have to do that yourself.
##IE:
-## FEEDBACK_TABLEPREFIX
+## FEEDBACK_TABLEPREFIX
## FEEDBACK_TABLEPREFIX SS13_
## Remove "SS13_" if you are using the standard schema file.
FEEDBACK_TABLEPREFIX SS13_
@@ -28,3 +28,7 @@ FEEDBACK_LOGIN username
## Password used to access the database.
FEEDBACK_PASSWORD password
+
+## Time in deciseconds for a query to execute before alerting a for possible slow query timeout.
+## While enabled all queries and their execution times are logged.
+#QUERY_DEBUG_LOG_TIMEOUT 70