Hi,
We have a changelog system where we write in a table when a record is changed.
When the user changes a record whey will, by code create an entry in a change log table.
At the same time a NAS i running and reading the changelog table.
This all works very nice but sometimes this creates a error from the NAS saying the record has been changed by another user.
We don't update a record after it has been inserted. When the NAS has read it, it will delete it.
We don't use any kind of manual locking.
We experience the problem mostly in Native dbs but also in SQL bases though the errormessage is a bit different.
The Native is running in a 5.1 client.
Hope you got some good ideas!
0
Comments
regards
We have _one_ codeunit for inserting in the changelog. And that is the only place where we insert in the table. No modify in that codeunit
Best regards
What kind of primary key are U using in logging table ? Integer (like "Entry No.") or some composite key ? Are U re-using the same PK values ?
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
And we needed to be more customized.
I looked a the code for the standard changelog but i couldn't see the difference in the way changes are inserted.
'Another user has modified the record' or something like 'another user has modified the Field table' ?
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Another user has modified the record for ChangeLog
"Entry No." '294383' after you retrieved it from the database.
Did you also runs the NAS process from a NAV client and start there the debugger?
<edit>added reference to MODIFY, good catch Slawek, obviously I meant both processes MODIFY the record, otherwise you wouldn't get the error</edit>
RIS Plus, LLC
MVP - Business Apps
No DenSter, if process 2 do some changes but does not fire MODIFY then the change is made only to local copy of rec in process 2 allocated memory. MODIFY in process 1 after return from process 2 will not give error in your example.
MODIFY have to be fired twice to get this error, this can happen even in the same process - there is only one condition that must be met - there must be two different variables defined of the same type, both must GET/FIND the record, (or one must GET/FIND a record and the second variable must copy rec content using TRANSFERFIELD(rec,TRUE), and then both must fire MODIFY.
BTW - Trouble is that ravnen says: . After re-thinking the problem it seems to me not possible to get 'Another user has modified record..' error message without any MODIFY.
Sometimes when NAS is serviced by event-driven procedures it happens that the same procedure is called second time (when another even comes) before it finished servicing the first event. Maybe NAS procedure is fired by some events, and it is called twice, and this second call is made before first call was completed. In such a scenario the same record will be read twice by two 'instances' of NAS procedure, but still without any MODIFY to log record the 'Another user has modified record' error message looks impossible to get to me.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
My solution stands though, the only way to get this error is when two processes change the same record and the message pops up when the second record is written to the database. To solve this issue they will need to debug the process to find out where it happens, and either retrieve the record before changing it, or passing it by reference to the other process.
RIS Plus, LLC
MVP - Business Apps
Good point.
Well, The NAS starts by opening the changelog and gets a record, process the record and afterwards deletes it.
I tried to use the NAV client instead and the error was thrown when the NAS tried to delete the changelog record.
Is it possible to have "dirty reads" from the database? So the record that the user created a changelog record from, was not modified or inserted because it generated an error, and thereby the changelog which was inserted, was removed again due to roleback?