Dirty Reads

ta5ta5 Member Posts: 1,164
Quite a while ago, I have seen a demo, showing the typical problem of a dirty read.

There was one process writing sales headers and sales lines, while another process was reading them for export purposes. Because no explicit lockings were issued, the read process (NAS with Timer) exported not always all lines for a given header, because when looping thrue the lines while the first process was still writing and at some point "line.next = 0" was true. This means the first process eventually wrote 10 sales lines, but the second process only exported 5 sales lines.

So this was quite logical to me and I wanted to build another example for a demo, but simplier:
On one client I start a codeunit that inserts a few records in table xy, at the end there is a confirm, waiting as long as I want. On another client I run a form on table xy, but the records are not there. No dirty reads!?

Platform: NAV 2009 SP1 on SQL Server 2008.

Whats wrong with this example? ](*,)
Thanks in avance.
Thomas

Answers

  • dmccraedmccrae Member, Microsoft Employee Posts: 144
    INSERTs are buffered before even being sent to the server, until another operation is issued (such as FIND), or until an explicit COMMIT, or implicit platform commit. This is why you dont see them.

    Try using "IF Rec.INSERT THEN;" instead - in this case the INSERTs are not buffered because the result of each INSERT is required immediately by the IF. Or you could make your test differently using MODIFY and look at the dirty reads of modified but uncommitted records.
    Dean McCrae - Senior Software Developer, NAV Server & Tools

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • ta5ta5 Member Posts: 1,164
    Hi dmccrae
    I have issued "if xy.find('-) then;" on the first client, just after the insert. It works now as expected, you have just made my afternoon! =D>
    Thanks a ton.
    Thomas
Sign In or Register to comment.