Question
· Jul 10, 2023

Is there a way to view/mount journals from another system on a local instance ?

I have several 1GB journals from a LIVE server that I would like to inspect (eg: check which globals have been updated over the time).

Is there a simple way to view those journals using another IRIS instance ? (eg: local installation).

I have been tempted to put those files directly into the journal folder of my local installation and restart the system, however I am concerned that the transactions they contains will be restored and will corrupt the local database.

I have checked documentation but couldn't find anything.

Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:39:22 EDT
Discussion (10)4
Log in or sign up to continue

You should definitely avoid putting strange journal files in your local journal directory! 

As Dmitry suggested, the Journal APIs will let you read the contents of a journal file. You can also use the existing Journal Profile utility for a general sense of which globals are most active in the file.

set path = ##class(%SYS.Journal.System).GetLastFileName() //example, use any journal file
do ##class(%CSP.UI.System.OpenJournalPane).ComputeJournalProfile(path)
zw:$ZV["Cach" ^CacheTemp.JournalProfile(path)
zw:$ZV["IRIS" ^IRIS.Temp.JournalProfile(path)

Here is what I end up using :     

set file = ##class(%File).%New("journal.txt")
set sc = file.Open("NW")

set path = ##class(%SYS.Journal.System).GetLastFileName()
set journal = ##class(%SYS.Journal.File).%OpenId(path)

set rec = journal.FirstRecord    
while $iso(rec)
{
    if (rec.TypeName = "SET") || (rec.TypeName = "KILL")
    {            
        do file.WriteLine(rec.Address_$c(9)_rec.TimeStamp_$c(9)_rec.ProcessID_$c(9)_rec.TypeName_$c(9)_rec.InTransaction_$c(9)_rec.GlobalNode_$c(9)_rec.DatabaseName)
    }
    set rec = rec.Next
}    

set journal = ""
do file.Close()

FYI:

You also use List query in %SYS.Journal.Record.

set rs=##class(%ResultSet).%New("%SYS.Journal.Record:List")
set jrn=##class(%SYS.Journal.System).GetLastFileName()  // or input file pull path
do rs.Execute(jrn)
write rs.Next()
write rs.Get("Address"),"-",rs.Get("TimeStamp"),"-",rs.Get("ProcessID"),"-",rs.Get("TypeName"),"-",rs.Get("InTransaction"),"-",rs.Get("GlobalNode"),"-",rs.Get("DatabaseName"),!
do rs.Close()

Note: it doesn't work with %SQL.Statement

Although in Japanese, this article is related to it : https://jp.community.intersystems.com/node/492721