Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG :VFP's Transactions are only corrected with bufferin
Message
From
13/12/2004 14:47:54
 
 
To
13/12/2004 13:47:32
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Beta
Miscellaneous
Thread ID:
00968242
Message ID:
00968876
Views:
7
Hi Fabio,

Perhaps the title for the thread should be: "I don't know how to work in multi-user environment, please help?" But, of course, it wouldn't look as cool as something like: "BUG: ... transactions incorrect!!!", would it?

As I explained in message #815257, VFP doesn't refresh record's content unless you ask it to. It might, but doesn't have to. There are many different factors play here, the bottom line is - if you don't make sure the record is refreshed, you shouldn't expect that VFP will always auto-magically do it for you.

What can be done to refresh record's content from disk:
Option #1: Lock the record.
Option #2: Set the second parameter of SET REFRESH to desired threshold and reread the record (GO RECNO()).
Option #3: Discard file cache (SYS(1104)), reread the record (GO RECNO()).

For this particular scenario, the following code can be used:
SYS(1104,100)
GO RECNO(100) IN 100
Thanks,
Aleksey.




>Aleksey, thanks.
>
>Well, i have post a optimistic title.
>
>The true title it is:
>VFP's Transactions are not corrected in general
>
>Now that you have focused the attention,
>I make to see to you one simpler situation:
>- No buffering
>- No transaction on the first session
>- Only one transaction on the second one, without buffering,
> with a flush force (useless of course).
>
>CODE WITH TRANSACTION:
>
>#DEFINE DBNAME SYS(2023)+'\DB______1'
>#DEFINE TABLENAME SYS(2023)+'\TABLE______1'
>
>* You changes the BUFFERINGMODE here
>#DEFINE _BUFFERINGMODE	1
>CLEAR
>ERASE FORCEEXT(DBNAME,'*')
>ERASE FORCEEXT(TABLENAME ,'*')
>* OPEN SESSION 1
>
>S1=CREATEOBJECT("SESSION")
>	SET DATASESSION TO S1.DATASESSIONID
>	* build a DBC for do the test
>	CREATE DATABASE DBNAME
>	CREATE TABLE TABLENAME ( F1 I)
>	APPEND BLANK
>	* relase exclusive access
>	CLOSE DATABASES
>	SET MULTILOCKS OFF
>	* open share
>	USE TABLENAME IN 100 ALIAS TABLE_ON_SESSION_1 SHARE
>	=CURSORSETPROP("Buffering",_BUFFERINGMODE,100)
>	GO TOP IN 100	
>	? [BUFFERING's table :],CURSORGETPROP("Buffering",100)
>	? ALIAS(100),"CURRENT RECNO()",RECNO(100),"CURRENT VALUE",TABLE_ON_SESSION_1.F1
>
>	********************************************************
>	* NOW SIMULATE ANOTHER SESSION, THIS WRITE ON THE TABLE NOW
>	=anotherSession('transaction_X')
>	********************************************************
>	SET DATASESSION TO S1.DATASESSIONID
>	?
>	? "EXTREME BUG: THE SESSION 1 WORKAREA IS NOT TOUCHED, THEN"
>	? "EXPECTED 2 because field value on disk it is 2"
>
>	? ALIAS(100),"CURRENT RECNO()",RECNO(100),"CURRENT VALUE",TABLE_ON_SESSION_1.F1
>	?
>	? "NOW RELEASE the table ( VFP release the file handle too"
>	USE IN 100
>	? "REOPEN THE TABLE, NOW THE VALUE IT IS CORRECT"
>	USE TABLENAME IN 100 ALIAS TABLE_ON_SESSION_1 EXCLUSIVE
>	? ALIAS(100),"CURRENT RECNO()",RECNO(100),"CURRENT VALUE",TABLE_ON_SESSION_1.F1
>	RELEASE S1
>CLOSE ALL
>ERASE FORCEEXT(TABLENAME ,'*')
>ERASE FORCEEXT(DBNAME,'*')
>
>PROCEDURE anotherSession(_alias)
>	?
>	? CHR(9),">>>>>>>SIMULATE ANOTHER TRANSACTION, THIS ADD 2 TO THE FIELD VALUE"
>	WITH CREATEOBJECT("SESSION")
>		SET DATASESSION TO .DATASESSIONID
>		USE TABLENAME ALIAS (m._alias) SHARED
>		? [BUFFERING's table :],CURSORGETPROP("Buffering")
>		BEGIN TRANSACTION
>			REPLACE F1 WITH F1+2
>		END TRANSACTION
>		? ALIAS(),"CURRENT RECNO()",RECNO(),"CURRENT VALUE",F1
>	ENDWITH
>	? CHR(9),">>>>>>>TRANSACTION IT IS CLOSED, FIELD HAVE VALUE 2"
>ENDPROC
>
>
>CODE WITHOUT TRANSACTION:
>
>#DEFINE DBNAME SYS(2023)+'\DB______1'
>#DEFINE TABLENAME SYS(2023)+'\TABLE______1'
>
>* You changes the BUFFERINGMODE here
>#DEFINE _BUFFERINGMODE	1
>CLEAR
>ERASE FORCEEXT(DBNAME,'*')
>ERASE FORCEEXT(TABLENAME ,'*')
>* OPEN SESSION 1
>
>S1=CREATEOBJECT("SESSION")
>	SET DATASESSION TO S1.DATASESSIONID
>	* build a DBC for do the test
>	CREATE DATABASE DBNAME
>	CREATE TABLE TABLENAME ( F1 I)
>	APPEND BLANK
>	* relase exclusive access
>	CLOSE DATABASES
>	SET MULTILOCKS OFF
>	* open share
>	USE TABLENAME IN 100 ALIAS TABLE_ON_SESSION_1 SHARE
>	=CURSORSETPROP("Buffering",_BUFFERINGMODE,100)
>	GO TOP IN 100	
>	? [BUFFERING's table :],CURSORGETPROP("Buffering",100)
>	? ALIAS(100),"CURRENT RECNO()",RECNO(100),"CURRENT VALUE",TABLE_ON_SESSION_1.F1
>
>	********************************************************
>	* NOW SIMULATE ANOTHER SESSION, THIS WRITE ON THE TABLE NOW
>	=anotherSession('transaction_X')
>	********************************************************
>	SET DATASESSION TO S1.DATASESSIONID
>	?
>	? "EXPECTED 2 because field value on disk it is 2"
>
>	? ALIAS(100),"CURRENT RECNO()",RECNO(100),"CURRENT VALUE",TABLE_ON_SESSION_1.F1
>	?
>	RELEASE S1
>CLOSE ALL
>ERASE FORCEEXT(TABLENAME ,'*')
>ERASE FORCEEXT(DBNAME,'*')
>
>PROCEDURE anotherSession(_alias)
>	?
>	? CHR(9),">>>>>>>SIMULATE ANOTHER TRANSACTION, THIS ADD 2 TO THE FIELD VALUE"
>	WITH CREATEOBJECT("SESSION")
>		SET DATASESSION TO .DATASESSIONID
>		USE TABLENAME ALIAS (m._alias) SHARED
>		? [BUFFERING's table :],CURSORGETPROP("Buffering")
>		REPLACE F1 WITH F1+2
>		? ALIAS(),"CURRENT RECNO()",RECNO(),"CURRENT VALUE",F1
>	ENDWITH
>	? CHR(9),">>>>>>>TRANSACTION IT IS CLOSED, FIELD HAVE VALUE 2"
>ENDPROC
>
>
>As you can observe,
>- if in the other session, the writing comes made within a transaction,
>the first session does not see the modifications made from the other;
>- If in the other session, the writing comes made without transaction,
>the first session does see the modifications made from the other.
>
>IMPORTANT:
>Now, if the cache it does not see the writings made from an other session of the same process, you can say like making to me in order to make to see them without to use a read lock ( ultra pessimistic )
>or to close and to reopen the table?

>
>If VFP works therefore, to open a shared local table is worth how much one disconnected view!
>
>Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform