Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MPT
Contributor III
Contributor III

The process cannot access the file because it is being used by another process

This is a pickle. I have a job that reads a database full of employee rows and loops that and creates an xml for each employee. There are several phases in the job where the xml file is appended with more and more content. This job has functioned without errors for years.

  

Now rather unexpectedly in October we started to see this error: tAdvancedFileOutputXML (The process cannot access the file because it is being used by another process). We run this job 3 times a day = 21 times a week and I have begun seeing this error about 3 times a week. It seems random which day and which hour and which tAdvancedFileOutputXML (1, 2 or 3) fails at any given time. There should be no race condition occurring where another process would try to move the file before the write is done.

 

Should I add tAdvancedFileOutputXML --> tSleep to make it less like likely to conflict? this seem very clumsy.

  

Should I implement tWaitForFile?

  

It bugs me that this has suddenly without obvious reasons become a problem since for years it has not caused any issues.

 

 

  • tMSSQLInput (get all employees)
  • Many employees? Yes, 2025 employees
    • loop employees one by one
      • Employee # 0001's personal details append into file (tAdvancedFileOutputXML_1) emp0001.xml
      • Employee has many contracts? Yes, 10
        • loop contracts one by one
          • contract info append into file (tAdvancedFileOutputXML_2) emp0001.xml
          • <contract><start>Jan 1 2023</start><end /><unit>7000</unit></contract>
          • <contract><start>Jan 1 2022</start><end>31 Dec 2022</end><unit>5500</unit></contract>
          • ...
      • Employee has many skills? Yes, 3
        • loop skills one by one
          • skill details append into file (tAdvancedFileOutputXML_3) emp0001.xml
          • <skill><title>First Aid</title><validUntil>31 Dec 2023</validUntil></skill>
          • <skill><title>Licensed Nurse</title><validUntil>31 Dec 2027</validUntil></skill>
          • ...
Labels (3)
1 Reply
SSong
Contributor II
Contributor II

As a workaround, maybe you could store all the employees' info into memory, so you can write it all at once at the end? It would be nice if there were a WaitForFileUnlock component. Maybe you can test the tFileProperties component to see if that mode_string provides you the correct write permission when the file is locked/unlocked - if so, you could use that in combination with a sleep component to sleep until the file is unlocked.