Wiki Home

Vfp Bug Seek Failing


Namespace: VFP
Here is an example of SEEK() failing under a heavy load of multiuser updates.

Run the following program in multiple sessions of VFP. With three sessions there is nearly always a failure, with two frequently. The same failure occurs when the code is run on a server from multiple PC's at the same time

Therefore...
Beware of indexes with FOR clauses when dealing with fast concurrent inserts.

SET DELETED ON
SET EXCLUSIVE OFF
SET MULTILOCKS ON

CLEAR

IF !FILE('Demo.dbf')
  CREATE TABLE Demo ( ;
         cKey C(4), ;
         nData I)
	
  * Note: Need the FOR clause below to make problem occur
  INDEX ON cKey TAG cKey FOR .t.
  APPEND BLANK
  REPLACE cKey WITH '1234'
  USE
ENDIF

USE Demo
CURSORSETPROP("Buffering", 5)  && optimistic table buffering 
lnError = 0
lnStart = SECONDS()
DO WHILE SECONDS() - lnStart < 60 AND lnError < 10
  IF SEEK('1234', 'Demo', 'cKey')
    REPLACE nData WITH nData + 1
    IF !TABLEUPDATE(1, .t.)
      ? 'Error in tableupdate'
    ENDIF
  ELSE
    lnError = lnError + 1
    ? 'ERROR in seek'
  ENDIF
ENDDO

? lnError
?? SECONDS() - lnStart

Contributors: Maurice De Beijer Steven Black
Category VFP Tips And Tricks Category VFP Bugs
( Topic last updated: 2000.06.06 03:06:27 AM )