Question Norman W. Freeman · 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

Comments

Luis Angel Pérez Ramos · Jul 10, 2023

Well, from my experience you will need the same databases on your local instance, so you will need to load a backup from the original into the local instance and after that apply the journal file generated after the creation of this backup from the original. 

0
Dmitry Maslennikov · Jul 10, 2023

You can read journal files from any instance, but using Journals API, not using management portal

0
Chad Severtson · Jul 10, 2023

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)
0
Norman W. Freeman · Jul 10, 2023

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()
0
Chad Severtson  Jul 11, 2023 to Norman W. Freeman

Great solution! 
I compared the performance against querying %SYS.Journal.Records:List and found that using the objects is >10 times faster. Oddly, I couldn't execute the query via %SQL.Statement. 

TestJournalFileNext    0.777671s                              

TestJournalResultSet: 10.972615s    

0
Mihoko Iijima · Jul 10, 2023

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 pathdo 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

0
Alexander Koblov · Jul 12, 2023

Also you should be able to open any journal file from the Management Portal View Journal -- replace path to a journal file in the URL and you should see its contents

0
Stuart Salzer · Jul 12, 2023

Although the interface is clunky for looking through large journal files, the startup cost is negligible:

%SYS>DO ^JRNDUMP

Select "G" for Goto

File: enter your filename which doesn't have to be and shouldn't be in the main journal directory.

At this point the interface is limited, but "F" for Find might help.

0