db_release_unused_handles (public)

 db_release_unused_handles [ -dbn dbn ]

Defined in packages/acs-tcl/tcl/01-database-procs.tcl

Releases any database handles that are presently unused.

Switches:
-dbn (optional)
The database name to use. If empty_string, uses the default database.

Partial Call Graph (max 5 caller/called nodes):
%3 test_db__caching db__caching (test acs-tcl) db_release_unused_handles db_release_unused_handles test_db__caching->db_release_unused_handles test_db__db_foreach db__db_foreach (test acs-tcl) test_db__db_foreach->db_release_unused_handles test_db__transaction_bug_3440 db__transaction_bug_3440 (test acs-tcl) test_db__transaction_bug_3440->db_release_unused_handles db_available_pools db_available_pools (public) db_release_unused_handles->db_available_pools db_state_array_name_is db_state_array_name_is (private) db_release_unused_handles->db_state_array_name_is ds_collect_db_call ds_collect_db_call (public) db_release_unused_handles->ds_collect_db_call ad_progress_bar_begin ad_progress_bar_begin (public) ad_progress_bar_begin->db_release_unused_handles adp_parse_ad_conn_file adp_parse_ad_conn_file (private) adp_parse_ad_conn_file->db_release_unused_handles apm_bootstrap_load_libraries apm_bootstrap_load_libraries (private) apm_bootstrap_load_libraries->db_release_unused_handles apm_files_load apm_files_load (private) apm_files_load->db_release_unused_handles apm_load_libraries apm_load_libraries (private) apm_load_libraries->db_release_unused_handles

Testcases:
db__db_foreach, db__caching, db__transaction_bug_3440
Source code:
        # we need the state array still for transaction handling
        upvar "#0" [db_state_array_name_is -dbn $dbn] db_state

        set pools [db_available_pools $dbn]
        set currentHandles [ns_db currenthandles]

        foreach pool $pools {
            if {[dict exists $currentHandles $pool]} {
                foreach {handle active} [dict get $currentHandles $pool] {
                    #ns_log notice "### FOUND pool $pool handle $handle active $active"
                    if {$active eq 0} {
                        # Don't release handles which are part of a transaction.
                        if { [info exists db_state(transaction_level,$handle)]
                             && $db_state(transaction_level,$handle) > 0
                         } {
                            continue
                        }
                        set start_time [expr {[clock clicks -microseconds]/1000.0}]
                        ns_db releasehandle $handle
                        #ns_log notice "### AFTER releasehandle [ns_db currenthandles $pool]"
                        ds_collect_db_call $handle releasehandle "" "" $start_time 0 ""
                    }
                }
            }
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: