Index: openacs-4/packages/acs-tcl/acs-tcl.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/acs-tcl.info,v
diff -u -r1.95.2.54 -r1.95.2.55
--- openacs-4/packages/acs-tcl/acs-tcl.info 26 Nov 2022 16:46:34 -0000 1.95.2.54
+++ openacs-4/packages/acs-tcl/acs-tcl.info 28 Nov 2022 17:49:22 -0000 1.95.2.55
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
The Kernel Tcl API library.
2021-09-15
@@ -18,7 +18,7 @@
GPL version 2
3
-
+
@@ -36,6 +36,7 @@
Activating this trace requires a new start of the server." section_name="tcltrace"/>
+
Index: openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl,v
diff -u -r1.1.2.43 -r1.1.2.44
--- openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 27 Nov 2022 17:55:10 -0000 1.1.2.43
+++ openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 28 Nov 2022 17:49:22 -0000 1.1.2.44
@@ -1319,9 +1319,17 @@
}
} error]
- # JCD: we log the clicks, dbname, query time, and statement to catch long running queries.
- # If we took more than 3 seconds yack about it.
- if { [clock clicks -milliseconds] - $start_time > 3000 } {
+ #
+ # If db_exec took more than a threshold, yack about it. We have to
+ # be careful there, since this might be called during bootstrap,
+ # where "parameter::get_from_package_key" is not yet defined. We
+ # cannot use "parameter::get_from_package_key" directly, since
+ # this needs an SQL query, leading to an infinite recursion. So,
+ # we use a per-thread variable, which is set at startup and then
+ # updated, whenever the parameter changes.
+ #
+ set complain_time [expr {[info exists ::acs::DbLogMinDuration] ? $::acs::DbLogMinDuration : 2000 }]
+ if { [clock clicks -milliseconds] - $start_time > $complain_time} {
set duration [format %.2f [expr {[clock clicks -milliseconds] - $start_time}]]
ns_log Warning "db_exec: longdb $duration ms $db $type $statement_name"
} else {
@@ -3836,8 +3844,56 @@
}
}
+ad_proc -public -callback subsite::parameter_changed -impl acs-tcl {
+ -package_id:required
+ -parameter:required
+ -value:required
+} {
+ Implementation of subsite::parameter_changed for acs-tcl.
+ @param package_id the package_id of the package the parameter was changed for
+ @param parameter the parameter name
+ @param value the new value
+
+} {
+ if {$parameter eq "DbLogMinDuration"} {
+ set new_value [expr {$value/1000.0}]
+ foreach pool [ns_db pools] {
+ set ns_db_old_value [ns_time format [ns_db logminduration $pool]]
+ set ns_db_old_ms [expr {int($ns_db_old_value * 1000)}]
+ set old_ms $::acs::DbLogMinDuration
+ ns_log notice "... pool $pool db old value $ns_db_old_value old_ms $old_ms ns_db_old_ms $ns_db_old_ms -> $new_value"
+ if {$ns_db_old_value > $new_value || $old_ms == $ns_db_old_ms} {
+ #
+ # If the "ns_db_old_value" is larger (less SQL
+ # logging) and the user wants more logging, then
+ # reduce it. If there is already a more detailed
+ # logging turned on then leave it as it is.
+ #
+ # If the old value was probably set via such parameter
+ # settings, adjust as well.
+ #
+ # Note that "ns_db logminduration ..." has only an
+ # effect when SQL logging is turned on.
+ #
+ # ns_logctl severity "Debug(sql)" on
+ #
+ ns_log notice "... adjust pool $pool old value $ns_db_old_value -> $new_value"
+ ns_db logminduration $pool $new_valuex
+ }
+ }
+ #
+ # We could use nsv instead of the per-thread variable, such as
+ # "nsv_set acs_properties DbLogMinDuration", which would be
+ # faster to change, but slower to test.
+ #
+ ns_eval [list set ::acs::DbLogMinDuration $value]
+ }
+}
+
+
+
# Local variables:
# mode: tcl
# tcl-indent-level: 4
Index: openacs-4/packages/acs-tcl/tcl/database-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/database-init.tcl,v
diff -u -r1.5 -r1.5.2.1
--- openacs-4/packages/acs-tcl/tcl/database-init.tcl 7 Aug 2017 23:47:59 -0000 1.5
+++ openacs-4/packages/acs-tcl/tcl/database-init.tcl 28 Nov 2022 17:49:22 -0000 1.5.2.1
@@ -12,6 +12,11 @@
ns_cache create db_cache_pool -size \
[parameter::get -package_id [ad_acs_kernel_id] -parameter DBCacheSize -default 50000]
+set ::acs::DbLogMinDuration [parameter::get_from_package_key \
+ -package_key acs-tcl \
+ -parameter DbLogMinDuration \
+ -default 2000]
+
# Local variables:
# mode: tcl
# tcl-indent-level: 4