Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

ErrorMode = 0: File locked by another QlikView Process

Hello,

I have a set of .qvd files and some documents that store/load data from them. The documents are scheduled in different time but sometimes (due to delays) they are running simoultaneously. If two documents trying to access the same .qvd at the same time the second one will find a lock and failed.

My goal is to resolve this situation automatically. I have tryed to implement something like

SET ErrorMode = 0;

STORE myTable INTO MyFilePath.qvd;

IF ScriptError > 0 THEN

  TRACE Data could not be stored in QVD, retrying...;

  SLEEP 5000; // 5 secs

  STORE myTable INTO MyFilePath.qvd;

ENDIF

So If the first attempt goes wrong I'll wait 5 seconds and try again. To simulate this I have opened with QlikView "MyFilePath.qvd" file and launched the reload of the main document. My issue is that the main document try to store the table in the file (that is locked), create an error and exit the procedure straight away.

It seems ignoring the ErrorMode = 0 that should force him to proceed on the script and wait 5 seconds before try again.

The returning error is "General Script Error". Does anyone faced this before? How can I resolve it? Are the "General Script Error" handled by QlikView? (On the QlikView documentation this error is not mapped on the ScriptError section)

Regards,

Daniele

10 Replies
Not applicable
Author

Hi Daniele,

Did you ever find a solution for this?  I am encoutering the same situation and would love to figure out a way to error trap and avoid the script failure.

Not applicable
Author

Hello Elizabeth,

  unfortunately the issue is still open.

I have posted the question 6 months ago and, so far, I had 284 views but no solution.

Regards,

Daniele

nicolett_yuri

You have two or more applications that write data to the same qvd file?

Why do not you write in different qvds and then when you use just add these two qvds in one file?

Not applicable
Author

I can't speak for Daniele, but in my situation I have one script that writes to a .QVD file and another that reads from the file.  I need a way for both to check and see if the .QVD is in use, and if it is to wait and access the .QVD file once the file is available again.  The issue I hit is that one of the scripts will try to access the file while the other has it locked, and of course the second script errors out.  I have done what I can with the schedule, but a good schedule is not a 100% guarantee that this error will be avoided.

Not applicable
Author

Elizabeth, you just described my situation so, yes, you can speak for me

Is there any way (in your situation) to schedule the "reader" process as sequential reload of the "writer"? In this way you force the 2 processes not to run simoultaneously.

I can't do it in my case.

Daniele.

flipside
Partner - Specialist II
Partner - Specialist II

One method could be to write a "file locked" code to another file, and have each of your processes read this code before proceeding, say 0000 shows the QVD is free, and anything else shows it is use.  Something like this ...

//Any locks in process?

let x = 0; //need to seed the loop timeout

Do while peek('currLock') <> '0000' and x < 10

       

        sleep 5000;

        x = x + 1;

        CurrLock:

        LOAD lockCode as currLock FROM LockCode.qvd (qvd);

loop;

if x = 10 then

    TRACE The file is in use by another process and I am not waiting any more so will force fail this reload;

    SLEEP 2000;

    LOAD XYZ RESIDENT XYZ; // or exit script

    exit script;

end if;

QVDLock:

LOAD * INLINE [

lockCode

1234]; //use a code specific to each document

   

Store QVDLock into LockCode.qvd;

TRACE I am starting your reload ...;

SLEEP 2000;

// ... load processes ...

//File unlock process

DROP TABLE QVDLock;

QVDUnlock:

LOAD * INLINE [

lockCode

0000];

Store QVDUnlock into LockCode.qvd;

flipside

Not applicable
Author

DanieleC,  unfortunately in my case I cannot run them sequentially either.  That would make life much easier!

flipside, that is a great idea, I wish I had thought of this earlier.  I am going to try this approach and see how it works, thanks!

Not applicable
Author

I'm having the same issue, but have not had time to realy test an idea out.

Making a for loop something like this:

set i = 0;

FOR i = 0 TO 1

 

/*

check file somehow

if file in use i = 1

else i = 0

*/

if $(i) = 0 then

store file into file.qvd(qvd);

exit for

Elseif i = 1

SLEEP 5000;

else

Next i

end if

marcelo_7
Creator
Creator

Perfect, thanks!