Hi,

Two years ago, I analyzed the behaviours using stream and %Persistent class.  

Class Test.Stream1 Extends %Persistent
{

Property st As %GlobalBinaryStream;

ClassMethod add1() As %Status
{
	; write stream in ^Test.Stream1S
	Set o = ..%New()
	Do o.st.Write("azeruiop")
	Quit o.%Save()
}

ClassMethod add2() As %Status
{
	; write stream in ^CacheStream
	Set o = ..%New()
	Set st = ##class(%GlobalBinaryStream).%New()
	Do st.Write("azeruiop")
	Set o.st = st
	Quit o.%Save()
}

Storage Default
{
<Data name="Stream1DefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>st</Value>
</Value>
</Data>
<DataLocation>^Test.Stream1D</DataLocation>
<DefaultData>Stream1DefaultData</DefaultData>
<IdLocation>^Test.Stream1D</IdLocation>
<IndexLocation>^Test.Stream1I</IndexLocation>
<StreamLocation>^Test.Stream1S</StreamLocation>
<Type>%Storage.Persistent</Type>
}

}

The method add2 use ^CacheStream due to the default storage usage (as described by @Robert Cemper ).  

However, We can force the storage in ^Test.Stream1S with :
Do st.%LocationSet("^Test.Stream1S")

Hello,

If you need an alternative, you can use the Config package in "%SYS"

Ex : 

New $Namespace
Set $Namespace = "%SYS"
Set properties("Database") = "YourPackageDatabaseCode"
Set sc = ##class(Config.MapPackages).Create("YourNameSpace","PackageName", .properties)
Quit sc

There is also a library to do this with a json configuration file config-api, but it's heavy just for a mapping.

Hi @Robert Cemper, @Vitaliy.Serdtsev 

Thank you for your replies!
I found a solution to do this without any change to an existing code, not simple but It works and could be useful in a critical situation.

I read the code of ^%ETN and see these lines :

UserError() s $zt="UserErrorE"
 i $d(^rOBJ("%ZERROR")) d 
 . n %00000 d ^%ZERROR

So, If we create a "%ZERROR" routine, we have an entry point :

ROUTINE %ZERROR

%ZERROR
    If $Data(^zForceCommit($Job)) { ; to avoid do this for all processes...
        While $TLEVEL {
            TCOMMIT
        }
    }

    Quit

And then, we must terminate the process like that:

Set pid = "1234" ; pid to terminate
Set ^zForceCommit(pid)=""
Zn "%SYS"
Set process = ##class(SYS.Process).%OpenId(pid)
Set sc = process.Terminate(1)

It's important to use the SYS.Process class and the Terminate method with argument 1 to use ^%ETN.

Hi @Robert Cemper !

Good Idea!

I tested, but unfortunately, It seems already too late, the rollback is already performed.

%ZSTOP routine

ROUTINE %ZSTOP
%ZSTOP
    Quit

SYSTEM
    Set ^zJob($i(^zJob)) = $ZDATETIME($HOROLOG, 3, 1) _" LABEL-SYSTEM (" _ $JOB _ ") "_$NAMESPACE _ " TLEVEL: "_$TLEVEL
    Do ZFORCECOMMIT
    Quit

LOGIN
    Quit
JOB
    Set ^zJob($i(^zJob)) = $ZDATETIME($HOROLOG, 3, 1) _" LABEL-JOB (" _ $JOB _ ") "_$NAMESPACE _ " TLEVEL: "_$TLEVEL
    Do ZFORCECOMMIT
    Quit
CALLLIN
    Quit

ZFORCECOMMIT
    If $Data(^zForceCommit($Job)) {
        While $TLEVEL {
            TCOMMIT
        }
    }
    Quit

Even if the process is in a transaction before "terminate", the ^zJob trace records a $TLEVEL with the value 0.

Maybe it's just not possible (or possible with a not documented procedure).

Thank you.

Hi @Benjamin De Boe,

Yes, I recently took a look, but indeed I need it on an old version  (2018 )

However, our customers should migrate but I think that i can't use DataMove on production systems before the end of 2023.

In my opinion, DataMove is complete but just needs to be wrapped for special use cases (ex: manage global mapping on mirror switch).  It's not a problem, we can do this easily with a simple global and ZSTART routine (such as the sample).  

Maybe, I should modify this tool in this way if there is an interest.

Hi @Alexey Maslov,


Interesting, we have the same problem and apply the same solution :-) !


There is more than 10 years ago, I have written an archiving tool to move document stream to a share and just keep the file reference. The process is long, but there is no downtime. It's exactly the same situation.

The archive tool is included in our application administration panel and the customer can decide himself to archive.  

Today, I have read-only globals nodes (not documents) that became very bigger. So, I try an approach with an "archive" database to reduce the volume of our main database(s).
If you are interested in global moving without downtime there is (live-global-mover)[https://openexchange.intersystems.com/package/isc-live-global-mover], but it's not designed for mirroring and ECP.