› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Help!! What is the problem??
All processes/threads were running fine and just found whole bunch of these messages in error db. What is the problem and how do I fix it?
[xlt :xlat:ERR /0:
Maybe the db was never closed after being opened for write.
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
gdbm_open $db_name
set rc_cd [catch {set int_acc_num [lindex [split [gdbm_fetch $db_name $key_val] ” “] 0]} err]
if {$rc_cd} {
echo ERROR_MESSAGE:$err
set int_acc_num “NOT_FOUND”
}
gdbm_close $db_name
set xlateOutVals $int_acc_num
You probably need to incorporate some re-try/error logic with respect to opening the database; if it attempts to open the database while it is open for write, then an error will be returned. You can do something like this:
#This code keeps attempting to open the database until successful #
set retcd 1
while { $retcd } {
set retcd [catch {gdbm_open $db_name}]
}
# End of open loop #
Hope this helps.
Jim Cobane
Henry Ford Health
I have very limited knwoledge about gdbm.
Is there a way to close an open db (a sort of reset function)?
All the messages in the threads that access gdbm are piling up in error db and the number is going up like crazy.. Please help!
To close it:
hcitcl gdbm_close /pathway/dbname
Examples of gdbm commands:
gdbm_list /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db # lists all keys in the db
gdbm_store /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db key content # writes into the db
gdbm_close /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db
gdbm_firstkey /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db # reads first key in the db
gdbm_nextkey /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db key # reads next key
gdbm_delete /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db key # deletes a key from the db
gdbm_fetch /hci/root3.8.1P/pmctest/exec/processes/prov_test_adt1/cerner.db key # reads a specific key
I would shut down any process that is accessing that database, and that should free the lock.
Jim Cobane
Henry Ford Health
You can open a database for writing (single-user mode) by only one instance of the tcl interpreter. If it is not open for writing, you can open it for reading (multi-user mode) by many instances.
You must have created the db file before you attempt any gdbm_open calls.
If you are placing the gdbm calls inside multiple xlates you will be fine as long as they are in the same CL process, and you add some code to make sure you don’t attempt to open it more than once. You will want to open it for writing. Opening the db only once within the process is fine. If using this inside xlates, you do not need to close the db.
If you are placing the gdbm code inside tcl procs for use outside the xlates, you have to implement your own file locking. For “multi-user access” the best option is to use tcl’s flockfunlock
When using flock with multiple files, particularly in multiple routines, always open and access the files in the same sequence and close them in the reverse order (unwind) so you can avoid deadlock problems.
When implementing the flock calls you use the options -read and -write. This allows multiple tcl instances to access the db for reading yet make them wait if an instance wants to open the db for writing. It also makes the write job wait if anyone has the file open for reading.
You can certainly play with this and test it by opening two telnet sessions, firing up hcitcl and entering the commands manually. You will see how access to the db by the two instances is controlled.
Email me if you would like some sample code.
You don’t say what version you are using, but starting around 5.3 rev something (we use AIX 5.3 Rev 2) a new process appeared: hcigdbm
If it is running, try killing it and running the script below from the hci command line. (Also, stop processes that use xlt_query_gdbm first.)
#!/hci/qdx5.3/integrator/bin/tcl
#
# test_gdbm.tcl
#
# Run this as the hci user before
# starting processes that use gdbm
# commands. This makes sure the
# hcigdbm server is operational.
#
set DBNAME TMP_TESTGDBM.dbm
set TESTVALUE “test value [clock format [clock seconds]]”
gdbm_open $DBNAME wc
gdbm_insert $DBNAME testkey $TESTVALUE
gdbm_close $DBNAME
gdbm_open $DBNAME r
set value_read [gdbm_fetch $DBNAME testkey]
if {[string compare $TESTVALUE $value_read] == 0} {
puts “SUCCESS: $TESTVALUE”
} else {
puts “DID NOT WORK”
}
file delete $DBNAME