Question
· Oct 26, 2023

Copy a file into global using %Stream <ILLEGAL VALUE>

Hi,

An exception occurs randomly.
I expect the value of ^TEST to be 20, but it's not.
Did i miss something like closing, flush the stream or locking the global?

Exception

%SaveData+15^%Stream.GlobalCharacter.1×PRAX1Í+^%SaveData+15^%Stream.GlobalCharacter.1^1)e^%SerializeObject+6^%Stream.Object.1^2e^%Save+9^%Stream.Object.1^93e^zCopyFromAndSave+58^%Stream.GlobalCharacter.1^1e^test+11^ry^1e^test+3^ry^4d^^^0

Testcode

test
    n glob s glob=$na(^TEST) k @glob
    n file s file="C:/temp/file.xslt"
    n i f i=1:1:20 w !,$$save(file,glob)
    q

save(file,glob) {
    s fs=##class(%Stream.FileBinary).%New()
    s sc=fs.LinkToFile(file)
    q:$System.Status.IsError(sc) sc
    s gs=##class(%Stream.GlobalBinary).%New(glob)
    s sc=gs.CopyFromAndSave(fs)
    q:$System.Status.IsError(sc) sc
    q gs.%Id()
}
Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:16:40 EDT
Discussion (13)1
Log in or sign up to continue

Thank you for your patience 😅,

I need to encapsulate it with $g, cuz ^TEST bekomes <UNDEFINED> sometimes. Subsequent invocations of the 'test' label sometimes lead to failures. Despite my attempts, the issue remains unresolved.

I tried the same code on. Cache for Windows (x86-64) 2017.1.1 (Build 111) Wed May 17 2017 15:55:41 EDT. It works without failing a single time.

Best regards

IRIS %Stream.GlobalCharacter uses $Sequence

Cache %Stream.GlobalCharacter uses $Increment

 
This modified version works without errors.

Could Intersystems consider introducing a parameter for using $increase instead of $sequence or provide a proper solution for this? It appears problematic to me that $sequence or the kernel does not know about a global that has already been killed. This testcase is quite simple, but I can't call it twice without extending a class i don't/shouldn't know much about.😅

The issue was successfully resolved with the assistance of Sascha Kisser through the WRC. A similar error has been fixed in the IRIS 2023.1.1 version. For my particular issue, it is necessary to set $sequence(@glob) to an empty string. Resolving the issue is straightforward for us, as we invoke it from a utility routine, and we are able to differentiate between Cache and IRIS using $ZV.