Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG :VFP's Transactions are only corrected with bufferin
Message
De
13/12/2004 13:47:32
 
 
À
13/12/2004 03:53:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Beta
Divers
Thread ID:
00968242
Message ID:
00968848
Vues:
5
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform