Error 3198

Hi,

We just got that error while 2 programs tries to store same key.
Last year we have just wrote a code that should prevent that error code,
but somehow it pops again (today for the first since writing).


repeat until #hold=true
  callnat 'x' #hold
end-repeat
rest #hold

x subprog


on error 3145
  reset #hold
  esacpe routine
end-error
reset #hold
read (1) x
  if false then
    update   /* for hold record
  end-if
end-read
#hold := true

How did we got that error if all programs uses that subprog x ???

Thank You
Hezi

the NAT3198 indicates that you are trying to store a duplicate value for a unique descriptor. The code you show only deals with putting records on hold. So how are you generating a value for your unique descriptor?

Hi,

The subprogram that use Read (1), read the last descriptor (Numerator), that was store in file, that why I read it with hold record, that no other will try to read it, before i perform ET.

Hezi

And than I add 1 for the new record

Hi Hezi,
How are you?
.
As Douglas says, you reported a NAT3198 error (in the posting’s Subject line), yet you only give information about a NAT3145 error (in the posting’s Body text).
.
Q) So which error do you get:

  • NAT3145 = record on Hold
    or
  • NAT3198 = duplicate value for a unique descriptor ?

Hi Hezi,

Are you assuming you came back from the subprogram still holding the record, and therefore preventing anyone else executing subprogram x from holding the same record?

This is simply not true. You released that record when you ended the read loop. The ISN was released from the hold queue by the time you came back with the RC call to Adabas.

Hi,

When the record is in hold I get 3145 but I catch it, with on error and escape the subprog ‘x’, to read it again (the endless loop).

Yes, I though to prevent others to get the last unique descriptor, I need to hold the record until I release it with ET (both the dummy update from subprog ‘x’ and my new record).
I thought I release the record in only 2 ways:1. perform ET, 2. the session is terminate.

The programs running in Online and Batch.

Hezi

Continue:

And somehow we got error 3198, while thinking we solved the issue.

Hezi

Although there is a Natural parameter to force an implicit ET at a module’s end, Brian, in most shops ETs are under the programmer’s control.

Hezi, what is the setting of the WH parameter? If ON, you will wait for the record to be released.

. User 1 Reads and holds record 100
. User2 attempts to read 100, but must wait
. User1 releases record 100 after creating record 101
. User2 is permitted to read record 100 with hold
. User 2 attempts to create record 101, but is issued 3198

Try setting WH=OFF to issue the 3145 immediately.

on error 3145
  reset #hold
  esacpe routine
end-error
SET GLOBALS WH=OFF    /* <---
reset #hold
read (1) x
  if false then
    update   /* for hold record
  end-if
end-read
#hold := true 

Hi,

I forgot to mentioned, bt default we run with WH=OFF.

Hezi

Hi,

I forgot to mentioned, bt default we run with WH=OFF.

Hezi

You don’t increment your counter in this subprogram by your example. This implies you have to release it at some point because you are going to read or get the record with hold in another place to increment the counter. In the meantime, someone else can proceed with subprogram X and assume the same counter. Hence response 198.

You can solve this one of two ways. If you don’t care about sequence number gaps, you can get and increment the counter first. If you do care about gaps, wait until the last moment when the whole transaction is a sure thing and grab and increment the counter.

Hi Brian,

I do Increment my counter after read the last one and holds it with update.
I release both records with ET, for preventing other to try to store new record.

Hezi

There is too much going on that is not evident with the information provided.

Can you re-create the NAT3198 in a test environment? If so, can you get the command logs (i.e., TEST DBLOG) so we can see what is held and what is released and the timing of any ET or BT that may be occurring?

Hezi - what is the “READ (1) x” actually doing to select the record? That is, is this a counter record that is held and updated to maintain the last value or is it something that selects the last record added in the database?

Well. no. I have tried for 2 days to recreate it with no luck.

The Read (1) get the last numerator (unique descriptor) and hold it in update mode tp prevent others to get the same last numerator

Hezi

HI,

Regarding the issue, I dived into our Plog, and I notice that one of the 2 jobs tried to perform Store, but got Backout.
It happened 2 times until the jod got abend.
In what conditions we can get Backout?

Thanks
Hezi

Beside the Natural command, there are Adabas-Timeouts, deadlocks, etc. But then you should get an NAT3009…