InterSystems 常见问题解答--日志文件长期保留而未被删除的原因
InterSystems 常见问题解答
如果系统24小时没有停止,旧的日志文件将根据“日志文件删除设置”在0:30删除。
导致日志文件保留的时间早于“日志文件删除设置”的一个可能原因是存在仍处于开放状态的事务。
在这种情况下,您将能够通过搜索执行事务的进程并完成事务来删除日志文件。
下面的示例检查是否存在未完成的事务,如果存在,则输出目标文件名和日志记录信息。
(示例可以从这里下载
*注意*如果要检查的日志文件较大或日志文件较多,则执行需要时间,因此请联系我们的支持中心。
Class ISJ.JournalUtility { ClassMethod GetOpenTransaction() As%Status { set status= $$$OK#dim ex As%Exception.AbstractException#dim rset As%ResultSettry { //current journal file write !, "Current journal file name:" , ##class ( %SYS.Journal.System ).GetCurrentFileName(),!! // Open transaction file // Get info about journals recorded in WIJ $$$ThrowOnError ( ##class ( %SYS.Journal.System ).GetImageJournalInfo(.filename,.jrnoffset,.jrnfilecount,.opentranoffset,.opentranfilecount)) if $get (opentranoffset)= "" { write !, "There are no open transactions" ,! return status } //If there is a differeence in file counts(jrnfilecount-opentranfilecount>0 ) // There is an open transaction in the old journal file, so please search for a target file name if jrnfilecount-opentranfilecount> 0 { set loopcnt=jrnfilecount-opentranfilecount for i= 1 : 1 :loopcnt { set currentfile=filename $$$ThrowOnError ( ##class ( %SYS.Journal.File ).GetPrev(currentfile,.filename)) } } write "〇〇 list of open target journal records 〇〇" ,! set rset= ##class ( %ResultSet ). %New ( "%SYS.Journal.Record:List" ) do rset. %Execute (filename,,,, $LB ( "Address" , "=" ,opentranoffset)) write !, "=== File Name : " ,filename, " ===" ,! write "Address : TimeStamp : ProcessID : RemoteSystemID : TypeName : Transaction" ,! while rset. %Next () { write rset. %Get ( "Address" ), " : " , rset. %Get ( "TimeStamp" ), " : " , rset. %Get ( "ProcessID" ), " : " , rset. %Get ( "RemoteSystemID" ), " : " , rset. %Get ( "TypeName" ), " : " , rset. %Get ( "InTransaction" ),! } } catch ex { set status=ex.AsStatus() } return status } }执行示例如下。
USER> do##class (ISJ.JournalUtility).GetOpenTransaction() Current journal file name:/usr/irissys/mgr/journal/ 20210330.002 〇〇 list of open target journal records 〇〇 === File Name : /usr/irissys/mgr/journal/ 20210330.001 === Address : TimeStamp : ProcessID : RemoteSystemID : TypeName : Transaction 1834156 : 2021 - 03 - 3013 : 19 : 00 : 5194 : 1073741824 : BeginTrans : 1