lLock par. problem in EditBaseRecord() for MariaDB - SOLVED

lLock par. problem in EditBaseRecord() for MariaDB - SOLVED

Postby Horizon » Tue Oct 22, 2019 6:38 am

Hi Mr. Rao,

Previous link is http://forums.fivetechsupport.com/viewtopic.php?f=3&t=37700

Can you please test it?

Thanks,
Last edited by Horizon on Sun Apr 12, 2020 11:43 am, edited 1 time in total.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby nageswaragunupudi » Tue Oct 22, 2019 9:46 am

We are working on this.
Kindly wait.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby nageswaragunupudi » Sat Nov 23, 2019 7:20 pm

Using the lLock parameter in the method EditBaseRecord() is not working satisfactorily.

We advise a different approach as in this following samples program. Please test and give your opinion.
Code: Select all  Expand view  RUN
#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oCn, oRs, oDlg, oFont, oBrw

   oCn   := FW_DemoDB()
   if oCn == nil
      return nil
   endif

   oRs   := oCn:RowSet( "SELECT ID,FIRST,CITY,SALARY FROM customer" )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,500 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "MARIADB LOCKED EDIT"

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs AUTOCOLS ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nEditTypes    := EDIT_GET
      :CreateFromCode()
   END

   @ 10,20 BTNBMP PROMPT "LockedEdit" SIZE 150,40 PIXEL OF oDlg FLAT ;
      ACTION LockedEdit( oBrw )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function LockedEdit( oBrw )

   local oRsMain, oRsEdit, oRec, nWait, oCn

   oRsMain  := oBrw:oDbf
   oCn      := oRsMain:oCn
   nWait    := oCn:QueryResult( "SHOW SESSION VARIABLES LIKE 'innodb_lock_wait_timeout'" )[ 2 ]
   oCn:Execute( "SET SESSION innodb_lock_wait_timeout = 1" )
   oCn:BeginTransaction()

   MsgRun( "Reading Record", "WAIT", { || ;
      oRsEdit := oCn:RowSet( "SELECT * FROM customer WHERE ID = ? FOR UPDATE", { oRsMain:ID } ) ;
      } )

   if oCn:nError == 0
      oCn:Execute( "SET SESSION innodb_lock_wait_timeout = " + cValToChar( nWait ) )
      oRec  := TDataRow():New( oRsEdit )
      oRec:Edit()
      oCn:CommitTransaction()
      oRsMain:ReSync()
      oBrw:RefreshCurrent()
   else
      oCn:RollBack()
      oCn:Execute( "SET SESSION innodb_lock_wait_timeout = " + cValToChar( nWait ) )
      ? "Record is locked by other user"
   endif
   oBrw:SetFocus()

return nil

//----------------------------------------------------------------------------//
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Sat Nov 23, 2019 7:59 pm

Thank you mr. Rao,

It seems it is working.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby nageswaragunupudi » Sun Nov 24, 2019 2:23 am

Thanks for the feedback.

Now we have modified the method EditBaseRecord() in the above lines. In our tests, it is working as expected.
The modification is being released in FWH1910.
The last parameter lLock can be a codeblock also. When read fails, this codeblock is executed with oRs as parameter.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Sun Nov 24, 2019 12:27 pm

nageswaragunupudi wrote:Thanks for the feedback.

Now we have modified the method EditBaseRecord() in the above lines. In our tests, it is working as expected.
The modification is being released in FWH1910.
The last parameter lLock can be a codeblock also. When read fails, this codeblock is executed with oRs as parameter.


Thank you master.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Wed Apr 01, 2020 9:29 am

nageswaragunupudi wrote:Thanks for the feedback.

Now we have modified the method EditBaseRecord() in the above lines. In our tests, it is working as expected.
The modification is being released in FWH1910.
The last parameter lLock can be a codeblock also. When read fails, this codeblock is executed with oRs as parameter.


Hi Mr. Rao,

The last parameter lLock can be a codeblock also. When read fails, this codeblock is executed with oRs as parameter.

Have you changed this?

October, November, December 2019
Code: Select all  Expand view  RUN
* FWMariaRowSet METHOD EditBaseRecord( cFieldList, lNew, bEdit, oBrw, lLock )
If lLock is set to .t. or a codeblock is specified, the record is locked while
reading and on failure to read, the codeblock is evaluated with the rowset as
parameter.
Till FWH1909, read is attempted with clause "LOCK IN SHARE MODE". This approach
was not giving the expected results as other users also are able to read the
record for lock and attempt to write was resulting in deadlock issues.
This is now modified to read with clause "FOR UPDATE". This change is working
as expected.
viewtopic.php?f=3&t=37928



Code: Select all  Expand view  RUN
    ::oRs_View:EditBaseRecord( nil, .f., { |oRec| ::GO_DETAYS(lMoveState, oRec ) }, ::oBrw, {|oRs|Locked_Problem(oRs)} )
 


if we set to .T. or codeblock lLock parameter, it gives an error.
Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\PrgW_SQL\Icra\IcraW.exe (32 bits)
   Size: ********* bytes
   Compiler version: Harbour 3.2.0dev (r1904111533)
   FiveWin  version: FWH 20.02
   C compiler version: Microsoft Visual C++ 19.20.27508 (32-bit)
   Windows version: 6.2, Build 9200

   Time from start: 0 hours 0 mins 6 secs
   Error occurred at: 01/04/2020, 12:27:17
   Error description: Error BASE/1081  Argument error: +
   Args:
     [   1] = C   SET @@TRANSACTION_ISOLATION = '
     [   2] = U  

Stack Calls
===========
   Called from:  => CHARACTER:__OPPLUS( 0 )
   Called from: .\source\internal\FWMARIA.PRG => FWMARIACONNECTION:INTRANSACTION( 6478 )
   Called from: .\source\internal\FWMARIA.PRG => (b)FWMARIACONNECTION( 5644 )
   Called from: .\source\internal\FWMARIA.PRG => FWMARIACONNECTION:BEGINTRANSACTION( 0 )
   Called from: .\source\internal\FWMARIA.PRG => FWMARIAROWSET:EDITBASERECORD( 4888 )
   Called from: .\TOb_Browse1_SQL.prg => TYK_LIST_SQL:GO_DETAY( 838 )
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Thu Apr 02, 2020 9:19 am

:oops:
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm


Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Thu Apr 02, 2020 8:18 pm

Hi,

Is it a MariaDB issue? Should i remove it and install again?

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby nageswaragunupudi » Fri Apr 03, 2020 2:34 am

Can you please try with .T. as the last parameter instead of codeblock?
Can you also let us know if you are using MySql or MariaDB and the version?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Fri Apr 03, 2020 8:28 am

Hi Mr. Rao,

nageswaragunupudi wrote:Can you please try with .T. as the last parameter instead of codeblock?

Yes, I have tried. same error gives.

Can you also let us know if you are using MySql or MariaDB and the version?

MariaDB 10.4.

Thanks.
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Sun Apr 05, 2020 9:20 am

I am Kindly wait. :)
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby Horizon » Tue Apr 07, 2020 8:50 am

up
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1322
Joined: Fri May 23, 2008 1:33 pm

Re: New lLock parameter problem in EditBaseRecord() for MariaDB

Postby nageswaragunupudi » Tue Apr 07, 2020 11:40 am

I have tested maria15.prg with 5th parameter as .T. on 4 different servers:

MySql
5.5.18
5.6.39
8.0.17

and MariaDB
5.5.5-10.3.7-MariaDB.

I did not notice any problem with any of these servers.
Please suggest any changes you suggest in maria15.prg to reproduce the error.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests