Hi all,
I have a query that is intended to delete outdated databases. This has been working but I recently found that if a database is locked the process stops with an error such as:
[db:lock] Database 'name' cannot be updated, it is opened by another process.
As a result, the process is stopped by any database being in a locked state. I would have thought that the try / catch around db:drop would catch the error and allow the process to skip over any locked databases.
declare variable $age external := 'PT1M'; (: age 1 minute for testing :)
let $cutoff := current-dateTime() - xs:dayTimeDuration($age) let $databases := db:list-details()[xs:dateTime(@modified-date) lt $cutoff] return ( admin:write-log('cleanup delete items older than ' || $cutoff), for $db in $databases return ( admin:write-log('cleanup deleting database ' || $db), try { db:drop($db) } catch * { admin:write-log('cleanup error deleting ' || $db || ': ' || $err:description, 'ERROR') } ) )
I tried replacing catch * with catch db:open to catch the specific error, but that hasn't helped.
Why is the error not caught, and is there a better way to write this query to avoid this problem?
Thanks, Vincent
______________________________________________
Vincent M. Lizzi
Head of Information Standards | Taylor & Francis Group
E-Mail: vincent.lizzi@taylorandfrancis.commailto:vincent.lizzi@taylorandfrancis.com
Web: www.tandfonline.comhttp://www.tandfonline.com/
Time zone: US Eastern
Taylor & Francis is a trading name of Informa UK Limited,
registered in England under no. 1072954
"Everything should be made as simple as possible, but not simpler."
[cid:8d80b1b7-f927-4cb7-a971-709e53dbf8b7]https://outlook.office.com/bookwithme/user/aa80d42cbb5b46dba06a5ad241d7665b@taylorandfrancis.com?anonymous&ep=owaSlotsEmailSignature Book time to meet with mehttps://outlook.office.com/bookwithme/user/aa80d42cbb5b46dba06a5ad241d7665b@taylorandfrancis.com?anonymous&ep=owaSlotsEmailSignature