NetTalk Central

Author Topic: File Error 30 - possible cause  (Read 4015 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
File Error 30 - possible cause
« on: June 04, 2014, 12:46:37 AM »
I am looking for an intermittent bug which posts an error message on the server:

'Entry not found [30] attempting to access a record from the Accelera file.'

The explanation for this error is:

'A GET to QUEUE has failed. For GET(Q,key), the matching key value was not found, and for GET(Q,pointer), the pointer is out of range'

This is odd because 'Accelera' (actually Acceleration) is a Memory file (IMDD) and I don't have anywhere in this application the commands GET from a Queue by Pointer or Key.  But assuming that the error is really related to this file I do have a question about concurrent processing of the file which maybe could cause an error.

I use Acceleration to store data based on Session Id.  To make sure that the file size is kept to a minimum, whenever I add records I first delete the existing records for that session viz:

   LOOP until Access:Acceleration.next()
        if ACC:SessionId not= UserSessionId then break.
        Access:Acceleration.DeleteRecord(0)
   END

The file is Threaded.  Is it possible that if two or more sessions are concurrently reading and deleting records that an access error could result because of the timing of events - is this code 'safe' in an NT application?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Rene Simons

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: File Error 30 - possible cause
« Reply #1 on: June 04, 2014, 05:02:31 AM »
Hi,

Maybe the file must be set first?
Or give it a non unique sessionid key field and use that to position first.

Rene
Rene Simons
NT14.14

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Error 30 - possible cause
« Reply #2 on: June 04, 2014, 06:30:41 AM »
It's impossible to comment on why your code is generating an error without seeing the actual code.

>> The file is Threaded.

fine - but all the threads are sharing the same "data" right? I mean, in the same way that all the users are shaing the same data if it was a TPS file.

>>  Is it possible that if two or more sessions are concurrently reading and deleting records that an access error could result because of the timing of events - is this code 'safe' in an NT application?

The memory driver is "Thread Safe". Whether your code is thread safe or not depends on what your code is doing. Trying to read a record, which has been deleted, would indeed give this sort of error.

Cheers
Bruce

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: File Error 30 - possible cause
« Reply #3 on: June 06, 2014, 12:29:49 AM »
Hi Rene, Bruce

I do a 'set' so as to just process a single Session Id.  Here is all of the code relating to the acceleration table:

!Delete any current records for this Session Id
   Relate:Acceleration.open()
   UserSessionId = p_web.SessionID
   ACC:SessionId = UserSessionId
   set(ACC:bySessionId,ACC:bySessionId)
   LOOP until Access:Acceleration.next()
        if ACC:SessionId not= UserSessionId then break.
        Access:Acceleration.DeleteRecord(0)
   END

( then add records per the code below)

   loop ct = 1 to 2001 by 5
       ACC:SessionId   = UserSessionId
       ACC:time            = AC:time[ct]
       ACC:dm              = AC:dm[ct]
       ACC:vkmph         = AC:vkmph[ct]
       ACC:ag                = AC:ag[ct]
       Access:Acceleration.insert()
   END   
   Relate:Acceleration.close()
     
I will be doing more testing on this but just wanted confirmation that there is not a glaring error in my approach i.e. that it is not possible (for example) that one thread is deleting the second last set of records and another thread is deleting the last set of records and the first thread will READ a record which belongs to the second set (it has to read past its own set so that it can determine that it is finished (via ' if ACC:SessionId not= UserSessionId then break.) and the second thread DELETEs that very record?

In other words, the two threads interact in the file at the junction of the sets of data and could there be problems that would cause Error 30?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File Error 30 - possible cause
« Reply #4 on: June 06, 2014, 03:35:44 AM »
could 2 threads for the same session attempt to do this at the same time?
If so then yes, you could get a case where the record disappears between the NEXT and the DELETE.

Perhaps you should do a simple DELETE(file) command - and handle the errors yourself?

Are you sure it is this code which is causing the original error?

Cheers
Bruce



Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: File Error 30 - possible cause
« Reply #5 on: June 06, 2014, 01:38:32 PM »
Hi Bruce

I'm not 100% sure that this is the code that is causing the error but only because the error (30) seems to relate to queues and Acceleration is not a queue.

But the code that I have reported here is the only code in my program where I delete records.  There are other places where I read the records.

But I have another idea.  Since I know that there will always be 401 records in the file that relate to a specific session id then I can LOOP 401 times from the start of the set of records which should mean that I will not access the next record of another set (which may be being deleted). That way I will never intersect with another thread.

I will test all of this of course but if it works out - that I can replicate the error with the current code and it goes away with the new then I think that I will have understood an important (and subtle) point about using a file to store variables that relate to a session (in this case 2005 discrete values).  It is that when I watched videos and read threads on the forum about using the file for variables there was an unstated assumption that the variables would be retrieved via the equivalent of a FETCH i.e. get the specific record out of the file based on session id.  The record would always be there and be uniquely accessible.  But this is not the way I have implemented it with my DELETEs and INSERTs and I may have allowed the possibility of a clash.

Thanks, I'll report later.

Keith

Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27