Why search for last record in No. Series Line table?

lvanvugt
Member Posts: 774
Due to the occurrence of too many locks on the No. Series Line table we stumbled over the following code in COD5704 and COD5705:
What is the use of the statement IF NoSeriesLine.FIND('+') THEN; as it will always take and - eventually - lock the last record in the No. Series Line table and thus always locking out the next proces that will execute the same codeunit?
Note
Code is from NAV 209 R2. The code is the same in 50 SP1 and in essence also the same in 2013.
NoSeriesLine.LOCKTABLE; IF NoSeriesLine.FIND('+') THEN; IF InvtSetup."Automatic Cost Posting" THEN BEGIN GLEntry.LOCKTABLE; IF GLEntry.FIND('+') THEN; END;Before this code there is no SETRANGE or SETFILTER statement for the NoSeriesLine variable. So this code is always picking out the last record in the No. Series Line table. And as this table is hardly updated this statement is always finding the same record, which functionality has no relation with the no. series used in a statement somewhat further down in both codeunits:
TransShptHeader."No. Series" := InvtSetup."Posted Transfer Shpt. Nos.";So my basic question is:
What is the use of the statement IF NoSeriesLine.FIND('+') THEN; as it will always take and - eventually - lock the last record in the No. Series Line table and thus always locking out the next proces that will execute the same codeunit?
Note
Code is from NAV 209 R2. The code is the same in 50 SP1 and in essence also the same in 2013.
0
Comments
-
Hi,lvanvugt wrote:So my basic question is:
What is the use of the statement IF NoSeriesLine.FIND('+') THEN; as it will always lock the last record in the No. Series Line table and thus Always locking out the next proces that will execute the same codeunit?
Just this. Exclusive access, ensuring that the lock actually holds true. Jörg Stryk explained it here.
As for the sense of it, I don't know. There are more strange things in warehouse functionality, like this performance issue. Thanks for pointing it out, though.
with best regards
Jens0 -
Hi Jens,
Exactly our thoughts when coming across it. Thanx for the confirmation.
For now we have build a workaround for this code which somehow looks like this:OurSetup.GET; CASE OurSetup."Deadlock Debug" OF OurSetup."Deadlock Debug"::SETRANGE: BEGIN NoSeriesLine.LOCKTABLE; NoSeriesLine.SETRANGE("Series Code", 'TV'); //hard coded for now to test it IF NoSeriesLine.FIND('+') THEN; END; OurSetup."Deadlock Debug"::ORIGINAL: BEGIN NoSeriesLine.LOCKTABLE; IF NoSeriesLine.FIND('+') THEN; END; END; IF InvtSetup."Automatic Cost Posting" THEN BEGIN GLEntry.LOCKTABLE; IF GLEntry.FIND('+') THEN; END;
The Deadlock Debug field in OurSetup is an option field with OptionString=ORIGINAL,SETRANGE,NOLOCK.
Currently we are using NOLOCK and it seems to work much better then ORIGINAL. We haven't tested SETRANGE yet in production as there was no need for it.
BTW: still interested on other's opinions on this matter.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions