Fetchall = False reopens connection

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Fetchall = False reopens connection

Post by lsc82 » Tue 12 Apr 2005 10:30

Hi,

I'm using D5, MyDac 3.50.19, MySQL 4.1.10.

The situation:

1 database with 1 table,
1 form with
1 tmyconnection
1 tmyquery (with fetchall=false)

When there is the first connection mysql log looks like:

12:13 126 connect user@machine on database
12:13 127 connect user@machine on database
query select * from table

than I change the SQL of the query, and open again:

12:14 128 connect user@machine on database
128 query select * from othertable

Is these multiple and repeated connections due to fetchall?
Is it necessary that one of these has to be recreated at change of the SQL statement?
Is it right that (apparently) the previous connection does not quit?

On some machine when I launch a program that repeatly change the SQL statement, I get error (10061) and the connection is broken... can this problem be due to my last question?

Thanks!

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Analisys of log files

Post by lsc82 » Tue 12 Apr 2005 10:48

I've seen one other thing:

The "lost" connection I described above is realy a "thread" that remains active.
When MySQL reach is 4096 limit of threads it refeuses new threads (so all new query that create one new thread).

Thanks!

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 12 Apr 2005 12:58

Using FetchAll = False requires creating an additional connection. You can read details about restrictions of this mode in MyDAC help.

For large data packets if to use FetchAll = False, time spent to establish a connection is insignificant.

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Post by lsc82 » Tue 12 Apr 2005 13:12

Yes, I know that the secondary connection is needed, and the time needed to estabilish is irrelevant.

The problem is that if you open and close continuosly the same tmyquery object, like

Code: Select all

for j := 1 to 10000 do
begin
q.open;
q.close;
end;
The mydac component does NOT close this secondary connection, but it creates a new one (WHY?)!
So mysql keeps in memory 10000 threads and after a while it doesn't accept any more request (the error is here)!

How can I solve this problem?

Thanks

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 12 Apr 2005 15:23

We couldn't reproduce the problem.
Please send us (mydac*crlab*com) complete small sample to demonstrate it.

Guest

looking for update

Post by Guest » Tue 19 Apr 2005 13:18

Ikar wrote:We couldn't reproduce the problem.
Please send us (mydac*crlab*com) complete small sample to demonstrate it.
Has a sample been supplied? As we have this issue, our work around is simple to trap the exception and then wait till mysql recovers.
Our environmnets are D6 and D7 with all updates.
latest version of mysql DAC and DBexpress.

thanks
alex

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Sample

Post by lsc82 » Tue 19 Apr 2005 13:43

Hi.

Here is my sample. If you need something else ask me. Thanks

My.Ini (MySQL 4.1.10a)

[winmysqladmin]
Server=C:/MySQL/bin/mysqld-max-nt.exe

[mysqld]
basedir=C:/MySQL
datadir=c:/Ariete2002/MySQL

memlock

query_cache_size=256
query_cache_limit=8M

bulk_insert_buffer_size=32M
innodb_data_file_path=dati1:256M;dati2:256M:autoextend

key_buffer_size=16M
innodb_buffer_pool_size=64M
innodb_additional_mem_pool_size=8M

innodb_file_per_table

innodb_log_file_size=64M
innodb_log_buffer_size=8M

max_connections=400
read_buffer_size=1M
sort_buffer_size=1M

wait_timeout=2147483
interactive_timeout=2147483

Form1

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Db, MemDS, DBAccess, MyAccess;

type
  TForm1 = class(TForm)
    MyConnection1: TMyConnection;
    e: TEdit;
    Button1: TButton;
    q: TMyQuery;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
for j := 1 to 10000 do 
begin 
q.open; 
q.close; 
end;
end;

end.

Form1.dfm

Code: Select all

  object MyConnection1: TMyConnection
    Database = 'sct'
    Username = 'Ariete2002'
    Password = 'accesso'
    Server = 'nbdavide'
    LoginPrompt = False
    Left = 92
    Top = 48
  end
  object q: TMyQuery
    Connection = MyConnection1
    FetchAll = False
    Left = 144
    Top = 48
    SQL.Strings = (
      'select * from tabella')
  end

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Wed 20 Apr 2005 09:58

We still couldn't reproduce your problem - new connections are created and destroyed at once.

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Other examples

Post by lsc82 » Sat 23 Apr 2005 08:42

I've run my little program above and after about 4000 cycles I have an exception:

EurekaLog 4.6.5

Application:
-------------------------------------------------------
1.1 Start Date : Sat, 23 Apr 2005 10:22:58 +0200
1.2 Name/Description: Project1.exe
1.3 Version Number :
1.4 Parameters :

Exception:
----------------------------------------------
2.1 Date : Sat, 23 Apr 2005 10:24:04 +0200
2.2 Address: 015C64E3
2.3 Module : mydac50.bpl
2.4 Type : SocketException
2.5 Message:

Active Controls:
-------------------------------------------
3.1 Form Class : rfb::win32::CViewClass
3.2 Form Text : SERVERK
3.3 Control Class: TButton
3.4 Control Text : Button1

Computer:
----------------------------
4.1 Name : LUCA
4.2 User : Luca
4.3 Total Memory: 511 Mb
4.4 Free Memory : 241 Mb
4.5 Total Disk : 57,26 Gb
4.6 Free Disk : 46,28 Gb

Operating System:
--------------------------------------
5.1 Type : Microsoft Windows 2000
5.2 Build # : 2195
5.3 Update : Service Pack 4
5.4 Language: Italiano (Italia)

Memory Dump

Registers:
-----------------------------
EAX: 01FA80A8 EDI: 7864A8C0
EBX: 01476E7C ESI: 01476E60
ECX: 00000000 ESP: 0143F288
EDX: 015C64E8 EIP: 015C64E3


Call Stack Information:

Code: Select all

------------------------------------------------------------------------------
|Address |Module      |Unit              |Class           |Procedure/Method   
------------------------------------------------------------------------------
|015C64E3|mydac50.bpl |Mysqlviotcp.pas   |TMySqlVioTcp    |Connect            
|015C711D|mydac50.bpl |Mysqlsession.pas  |TMySqlSession   |Connect            
|40002C34|Vcl50.bpl   |System.pas        |                |_GetMem            
|40004AE4|Vcl50.bpl   |System.pas        |                |_LStrClr           
|015C6F88|mydac50.bpl |Mysqlsession.pas  |TMySqlSession   |Connect            
|015C8DD3|mydac50.bpl |Mysqlapidirect.pas|TMySQLAPIDirect |mysql_real_connect 
|015CCE33|mydac50.bpl |Myclasses.pas     |TMySQLConnection|Connect            
|015CFA2C|mydac50.bpl |Myclasses.pas     |TMySQLRecordset |QuerySwapConnection
|015CF905|mydac50.bpl |Myclasses.pas     |TMySQLRecordset |ExecCommand        
|01556EFE|dac50.bpl   |Craccess.pas      |TCRRecordSet    |ExecFetch          
|01556DF8|dac50.bpl   |Craccess.pas      |TCRRecordSet    |InternalOpen       
|01556DCC|dac50.bpl   |Craccess.pas      |TCRRecordSet    |InternalOpen       
|015CFC97|mydac50.bpl |Myclasses.pas     |TMySQLRecordset |InternalOpen       
|015478F6|dac50.bpl   |Memdata.pas       |TData           |Open               
|015478C8|dac50.bpl   |Memdata.pas       |TData           |Open               
|0154E6D8|dac50.bpl   |Memdata.pas       |TMemData        |Open               
|01556ECC|dac50.bpl   |Craccess.pas      |TCRRecordSet    |Open               
|015529DB|dac50.bpl   |Memds.pas         |TMemDataSet     |InternalOpen       
|015529CC|dac50.bpl   |Memds.pas         |TMemDataSet     |InternalOpen       
|015626ED|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|InternalOpen       
|0156265C|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|InternalOpen       
|015DB162|mydac50.bpl |Myaccess.pas      |TCustomMyDataSet|InternalOpen       
|405C5044|Vcldb50.bpl |Db.pas            |TDataSet        |DoInternalOpen     
|405C50F8|Vcldb50.bpl |Db.pas            |TDataSet        |OpenCursor         
|01552B96|dac50.bpl   |Memds.pas         |TMemDataSet     |OpenCursor         
|01552B8C|dac50.bpl   |Memds.pas         |TMemDataSet     |OpenCursor         
|0155EB91|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|OpenCursor         
|0155EAC4|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|OpenCursor         
|015DA9EC|mydac50.bpl |Myaccess.pas      |TCustomMyDataSet|OpenCursor         
|405C4FD1|Vcldb50.bpl |Db.pas            |TDataSet        |SetActive          
|405C4F7C|Vcldb50.bpl |Db.pas            |TDataSet        |SetActive          
|0155EABE|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|SetActive          
|0155EA94|dac50.bpl   |Dbaccess.pas      |TCustomDADataSet|SetActive          
|015DAE51|mydac50.bpl |Myaccess.pas      |TCustomMyDataSet|SetActive          
|405C4E74|Vcldb50.bpl |Db.pas            |TDataSet        |Open               
|405C4E70|Vcldb50.bpl |Db.pas            |TDataSet        |Open               
|00420062|Project1.exe|Unit1.pas         |TForm1          |Button1Click       
|4006B8F0|Vcl50.bpl   |Controls.pas      |TControl        |Click              
|40003CAC|Vcl50.bpl   |System.pas        |                |_CallDynaInst      
|40047FBC|Vcl50.bpl   |Stdctrls.pas      |TButton         |CNCommand          
|4006B6B0|Vcl50.bpl   |Controls.pas      |TControl        |WndProc            
|4006E376|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|77E1A205|user32.dll  |                  |                |GetClassNameA      
|4006E1A4|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|40047E3C|Vcl50.bpl   |Stdctrls.pas      |TButtonControl  |WndProc            
|4006B608|Vcl50.bpl   |Controls.pas      |TControl        |Perform            
|4006B5E4|Vcl50.bpl   |Controls.pas      |TControl        |Perform            
|4006EAFB|Vcl50.bpl   |Controls.pas      |TWinControl     |WMCommand          
|4006EAF0|Vcl50.bpl   |Controls.pas      |TWinControl     |WMCommand          
|4006B6B0|Vcl50.bpl   |Controls.pas      |TControl        |WndProc            
|4006E376|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|77E1A361|user32.dll  |                  |                |CallNextHookEx     
|4006E1A4|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|40054112|Vcl50.bpl   |Forms.pas         |TCustomForm     |WndProc            
|4006DF78|Vcl50.bpl   |Controls.pas      |TWinControl     |MainWndProc        
|77E2506E|user32.dll  |                  |                |CallWindowProcW    
|77E1735C|user32.dll  |                  |                |SendMessageW       
|77E1731D|user32.dll  |                  |                |SendMessageW       
|77E16B5F|user32.dll  |                  |                |CallWindowProcA    
|77E16B4B|user32.dll  |                  |                |CallWindowProcA    
|4006E44E|Vcl50.bpl   |Controls.pas      |TWinControl     |DefaultHandler     
|4006BCE4|Vcl50.bpl   |Controls.pas      |TControl        |WMLButtonUp        
|4006B6B0|Vcl50.bpl   |Controls.pas      |TControl        |WndProc            
|4006E376|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|77E1A38D|user32.dll  |                  |                |CallNextHookEx     
|4006E1A4|Vcl50.bpl   |Controls.pas      |TWinControl     |WndProc            
|40047E3C|Vcl50.bpl   |Stdctrls.pas      |TButtonControl  |WndProc            
|4006DF78|Vcl50.bpl   |Controls.pas      |TWinControl     |MainWndProc        
|77E156F5|user32.dll  |                  |                |PeekMessageA       
|77E15B72|user32.dll  |                  |                |DispatchMessageA   
|77E15B6C|user32.dll  |                  |                |DispatchMessageA   
|4005AA04|Vcl50.bpl   |Forms.pas         |TApplication    |ProcessMessage     
|4005AAB4|Vcl50.bpl   |Forms.pas         |TApplication    |HandleMessage      
|4005ACC9|Vcl50.bpl   |Forms.pas         |TApplication    |Run                
|4005AC48|Vcl50.bpl   |Forms.pas         |TApplication    |Run                
|00420427|Project1.exe|Project1.dpr      |                |                   
------------------------------------------------------------------------------

Code: Select all

Stack:               Memory Dump:
------------------   ---------------------------------------------------------------------------
0143F288: 0143F2C0   015C64E3: E8 F8 AB FE FF 8B 45 E8 E8 90 FD FF FF B2 01 8B  ......E.........
0143F28C: 015C651E   015C64F3: 45 E8 E8 CA FD FF FF 8B 45 E8 8B 40 0C 8B 55 E8  [email protected].
0143F290: 0143F2B8   015C6503: C7 42 0C FF FF FF FF 8B D0 8B 45 E8 8B 08 FF 51  .B........E....Q
0143F294: 01F7EFC4   015C6513: 04 33 C0 5A 59 59 64 89 10 EB 2D E9 A5 AB FE FF  .3.ZYYd...-.....
0143F298: 00000022   015C6523: 8B 45 E8 33 D2 89 50 14 8B 45 E8 8B 40 10 50 E8  [email protected].
0143F29C: 01FA88C4   015C6533: AD 2F FF FF 8B 45 E8 C7 40 10 FF FF FF FF E8 A2  ./...E..@.......
0143F2A0: 01F7D18C   015C6543: AB FE FF E8 A5 AB FE FF 5F 5E 5B 8B E5 5D C3 00  ........_^[..]..
0143F2A4: EA0C0002   015C6553: 00 FF FF FF FF 2F 00 00 00 64 3A 5C 50 72 6F 6A  ...../...d:\Proj
0143F2A8: 7864A8C0   015C6563: 65 63 74 73 5C 44 65 6C 70 68 69 5C 4D 79 64 61  ects\Delphi\Myda
0143F2AC: 00000000   015C6573: 63 5C 53 6F 75 72 63 65 5C 4D 79 53 71 6C 56 69  c\Source\MySqlVi
0143F2B0: 00000000   015C6583: 6F 54 63 70 2E 70 61 73 00 FF FF FF FF 11 00 00  oTcp.pas........
0143F2B4: 7864A8C0   015C6593: 00 41 73 73 65 72 74 69 6F 6E 20 66 61 69 6C 75  .Assertion failu
0143F2B8: 0143F30C   015C65A3: 72 65 00 00 00 FF FF FF FF 09 00 00 00 6C 6F 63  re...........loc
0143F2BC: 015C7120   015C65B3: 61 6C 68 6F 73 74 00 00 00 53 8B D8 83 7B 10 FF  alhost...S...{..
0143F2C0: 0143F2CC   015C65C3: 75 14 B9 EE 00 00 00 BA 04 66 5C 01 B8 3C 66 5C  u........f\..<f\0143F2C4: 015C712A   015C65D3: 01 E8 3F AB FE FF 6A 02 8B 43 10 50 E8 38 2F FF  ..?...j..C.P.8/.
This is mysql general log at the beginning and at the end of the loop...

Code: Select all

050423 10:22:04	      6 Connect     Ariete2002@LUCA on sct
		      7 Connect     Ariete2002@LUCA on sct
		      7 Query       SELECT * FROM janacli
050423 10:22:10	      8 Connect     Ariete2002@LUCA on sct
		      8 Query       SELECT * FROM janacli
050423 10:22:15	      9 Connect     Ariete2002@LUCA on sct
		      9 Query       SELECT * FROM janacli
		     10 Connect     Ariete2002@LUCA on sct
		     10 Query       SELECT * FROM janacli
		     11 Connect     Ariete2002@LUCA on sct
		     11 Query       SELECT * FROM janacli
050423 10:22:16	     12 Connect     Ariete2002@LUCA on sct
		     12 Query       SELECT * FROM janacli
		     13 Connect     Ariete2002@LUCA on sct
		     13 Query       SELECT * FROM janacli
		     14 Connect     Ariete2002@LUCA on sct
		     14 Query       SELECT * FROM janacli

[...]

050423 10:23:55	   3886 Connect     Ariete2002@LUCA on sct
		   3886 Query       SELECT * FROM janacli
		   3887 Connect     Ariete2002@LUCA on sct
		   3887 Query       SELECT * FROM janacli
		   3888 Connect     Ariete2002@LUCA on sct
		   3888 Query       SELECT * FROM janacli
		   3889 Connect     Ariete2002@LUCA on sct
		   3889 Query       SELECT * FROM janacli
		   3890 Connect     Ariete2002@LUCA on sct
		   3890 Query       SELECT * FROM janacli
		   3891 Connect     Ariete2002@LUCA on sct
		   3891 Query       SELECT * FROM janacli
		   3892 Connect     Ariete2002@LUCA on sct
		   3892 Query       SELECT * FROM janacli
		   3893 Connect     Ariete2002@LUCA on sct
		   3893 Query       SELECT * FROM janacli
		   3894 Connect     Ariete2002@LUCA on sct
		   3894 Query       SELECT * FROM janacli
		   3895 Connect     Ariete2002@LUCA on sct
		   3895 Query       SELECT * FROM janacli
		   3896 Connect     Ariete2002@LUCA on sct
		   3896 Query       SELECT * FROM janacli
		   3897 Connect     Ariete2002@LUCA on sct
		   3897 Query       SELECT * FROM janacli
		   3898 Connect     Ariete2002@LUCA on sct
		   3898 Query       SELECT * FROM janacli
		   3899 Connect     Ariete2002@LUCA on sct
		   3899 Query       SELECT * FROM janacli
		   3900 Connect     Ariete2002@LUCA on sct
		   3900 Query       SELECT * FROM janacli
		   3901 Connect     Ariete2002@LUCA on sct
		   3901 Query       SELECT * FROM janacli
		   3902 Connect     Ariete2002@LUCA on sct
		   3902 Query       SELECT * FROM janacli
		   3903 Connect     Ariete2002@LUCA on sct
		   3903 Query       SELECT * FROM janacli
		   3904 Connect     Ariete2002@LUCA on sct
		   3904 Query       SELECT * FROM janacli
		   3905 Connect     Ariete2002@LUCA on sct
		   3905 Query       SELECT * FROM janacli
		   3906 Connect     Ariete2002@LUCA on sct
		   3906 Query       SELECT * FROM janacli
		   3907 Connect     Ariete2002@LUCA on sct
		   3907 Query       SELECT * FROM janacli
		   3908 Connect     Ariete2002@LUCA on sct
		   3908 Query       SELECT * FROM janacli
		   3909 Connect     Ariete2002@LUCA on sct
		   3909 Query       SELECT * FROM janacli
		   3910 Connect     Ariete2002@LUCA on sct
		   3910 Query       SELECT * FROM janacli
		   3911 Connect     Ariete2002@LUCA on sct
		   3911 Query       SELECT * FROM janacli
		   3912 Connect     Ariete2002@LUCA on sct
		   3912 Query       SELECT * FROM janacli
		   3913 Connect     Ariete2002@LUCA on sct
		   3913 Query       SELECT * FROM janacli
		   3914 Connect     Ariete2002@LUCA on sct
		   3914 Query       SELECT * FROM janacli
		   3915 Connect     Ariete2002@LUCA on sct
		   3915 Query       SELECT * FROM janacli
		   3916 Connect     Ariete2002@LUCA on sct
		   3916 Query       SELECT * FROM janacli
		   3917 Connect     Ariete2002@LUCA on sct
		   3917 Query       SELECT * FROM janacli
		   3918 Connect     Ariete2002@LUCA on sct
		   3918 Query       SELECT * FROM janacli
		   3919 Connect     Ariete2002@LUCA on sct
		   3919 Query       SELECT * FROM janacli
		   3920 Connect     Ariete2002@LUCA on sct
		   3920 Query       SELECT * FROM janacli
		   3921 Connect     Ariete2002@LUCA on sct
		   3921 Query       SELECT * FROM janacli
		   3922 Connect     Ariete2002@LUCA on sct
		   3922 Query       SELECT * FROM janacli
		   3923 Connect     Ariete2002@LUCA on sct
		   3923 Query       SELECT * FROM janacli
		   3924 Connect     Ariete2002@LUCA on sct
		   3924 Query       SELECT * FROM janacli
		   3925 Connect     Ariete2002@LUCA on sct
		   3925 Query       SELECT * FROM janacli
		   3926 Connect     Ariete2002@LUCA on sct
		   3926 Query       SELECT * FROM janacli
		   3927 Connect     Ariete2002@LUCA on sct
		   3927 Query       SELECT * FROM janacli
		   3928 Connect     Ariete2002@LUCA on sct
		   3928 Query       SELECT * FROM janacli
		   3929 Connect     Ariete2002@LUCA on sct
		   3929 Query       SELECT * FROM janacli
		   3930 Connect     Ariete2002@LUCA on sct
		   3930 Query       SELECT * FROM janacli
		   3931 Connect     Ariete2002@LUCA on sct
		   3931 Query       SELECT * FROM janacli
		   3932 Connect     Ariete2002@LUCA on sct
		   3932 Query       SELECT * FROM janacli
		   3933 Connect     Ariete2002@LUCA on sct
		   3933 Query       SELECT * FROM janacli
		   3934 Connect     Ariete2002@LUCA on sct
		   3934 Query       SELECT * FROM janacli
		   3935 Connect     Ariete2002@LUCA on sct
		   3935 Query       SELECT * FROM janacli
		   3936 Connect     Ariete2002@LUCA on sct
		   3936 Query       SELECT * FROM janacli
		   3937 Connect     Ariete2002@LUCA on sct
		   3937 Query       SELECT * FROM janacli
		   3938 Connect     Ariete2002@LUCA on sct
		   3938 Query       SELECT * FROM janacli
		   3939 Connect     Ariete2002@LUCA on sct
		   3939 Query       SELECT * FROM janacli
		   3940 Connect     Ariete2002@LUCA on sct
		   3940 Query       SELECT * FROM janacli
		   3941 Connect     Ariete2002@LUCA on sct
		   3941 Query       SELECT * FROM janacli
		   3942 Connect     Ariete2002@LUCA on sct
		   3942 Query       SELECT * FROM janacli
		   3943 Connect     Ariete2002@LUCA on sct
		   3943 Query       SELECT * FROM janacli
		   3944 Connect     Ariete2002@LUCA on sct
		   3944 Query       SELECT * FROM janacli
050423 10:23:56	   3945 Connect     Ariete2002@LUCA on sct
		   3945 Query       SELECT * FROM janacli
		   3946 Connect     Ariete2002@LUCA on sct
		   3946 Query       SELECT * FROM janacli
		   3947 Connect     Ariete2002@LUCA on sct
		   3947 Query       SELECT * FROM janacli
		   3948 Connect     Ariete2002@LUCA on sct
		   3948 Query       SELECT * FROM janacli
		   3949 Connect     Ariete2002@LUCA on sct
		   3949 Query       SELECT * FROM janacli
		   3950 Connect     Ariete2002@LUCA on sct
		   3950 Query       SELECT * FROM janacli
		   3951 Connect     Ariete2002@LUCA on sct
		   3951 Query       SELECT * FROM janacli
		   3952 Connect     Ariete2002@LUCA on sct
		   3952 Query       SELECT * FROM janacli
		   3953 Connect     Ariete2002@LUCA on sct
		   3953 Query       SELECT * FROM janacli
		   3954 Connect     Ariete2002@LUCA on sct
		   3954 Query       SELECT * FROM janacli
		   3955 Connect     Ariete2002@LUCA on sct
		   3955 Query       SELECT * FROM janacli
		   3956 Connect     Ariete2002@LUCA on sct
		   3956 Query       SELECT * FROM janacli
		   3957 Connect     Ariete2002@LUCA on sct
		   3957 Query       SELECT * FROM janacli
		   3958 Connect     Ariete2002@LUCA on sct
		   3958 Query       SELECT * FROM janacli
		   3959 Connect     Ariete2002@LUCA on sct
		   3959 Query       SELECT * FROM janacli
		   3960 Connect     Ariete2002@LUCA on sct
		   3960 Query       SELECT * FROM janacli
		   3961 Connect     Ariete2002@LUCA on sct
		   3961 Query       SELECT * FROM janacli
		   3962 Connect     Ariete2002@LUCA on sct
		   3962 Query       SELECT * FROM janacli
		   3963 Connect     Ariete2002@LUCA on sct
		   3963 Query       SELECT * FROM janacli
		   3964 Connect     Ariete2002@LUCA on sct
		   3964 Query       SELECT * FROM janacli
		   3965 Connect     Ariete2002@LUCA on sct
		   3965 Query       SELECT * FROM janacli
		   3966 Connect     Ariete2002@LUCA on sct
		   3966 Query       SELECT * FROM janacli
		   3967 Connect     Ariete2002@LUCA on sct
		   3967 Query       SELECT * FROM janacli
		   3968 Connect     Ariete2002@LUCA on sct
		   3968 Query       SELECT * FROM janacli
		   3969 Connect     Ariete2002@LUCA on sct
		   3969 Query       SELECT * FROM janacli
		   3970 Connect     Ariete2002@LUCA on sct
		   3970 Query       SELECT * FROM janacli
		   3971 Connect     Ariete2002@LUCA on sct
		   3971 Query       SELECT * FROM janacli
As you can see, it open 2 times the connections at the first connect (due to fetchall) and at every (close, open), it open a new connection, without closing the old one.

Any idea?

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Other observation

Post by lsc82 » Sat 23 Apr 2005 09:06

I've try to find a work around... but it is inusable...

Code: Select all

   for j := 1 to 10000 do 
      begin 
      q.open; 
      q.close; 
      // 
      c.Disconnect;    //c is the tmyconnection 
      c.Connect; 
      end; 

Without the disconnect/connect, the loop arrives at 3970.
With the 2 instructions apparently the problem does not exists.

Thanks

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 25 Apr 2005 11:18

Dump you sent us confirms that a connection wasn't closed. Please reproduce the problem at the small complete sample and send us it.

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Post by lsc82 » Tue 26 Apr 2005 07:02

I'm still analyzing the problem to reproduce it and I've seen that it seems to appear only on win xp or win 2003 machine.
By now this thing seems to be the only difference between machines where the problem exists and machine where it does not.

Thanks

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Post by lsc82 » Tue 26 Apr 2005 09:12

I cannot find a work around to the problem.

I'm sending you the sample program by email. The code of the program is:

Code: Select all

var j: Integer;
begin
   c.Username := CUser.Text;
   c.Password := CPassword.Text;
   c.Server   := CServer.Text;
   c.Database := CDB.Text;
   c.Connect;
   //
   q.SQL.Text := 'select * from ' + CTable.Text;
   //
   for j := 1 to 10000 do
      begin
      CAPTION := IntToStr(j);
      application.ProcessMessages;
      q.open;
      q.close;
      end;
end;
Try stress the program, running 2-3 times the program at the same moment, and wait it arrives at 10.000. Than hit again the Try button, to force the loop again.

Thanks

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Post by lsc82 » Tue 26 Apr 2005 16:44

I've just bought your Professional version. Now I can follow the flow of component's instructions.

The strange thing is that when I go "slow" (F7) executing the close statement, mysql log change to:

Code: Select all

15 Connect
15 Query
15 Quit
16 Connect
16 Query
16 Quit
but when I go "fast" (F9) it returns to be:

Code: Select all

17 Connect
17 Query
18 Connect
18 Query
In other words, I suppose that for one strange reason there is a "timing" error on this net comunications, so MySQL does not receive the "Quit" command.
Perhaps this problem could be bound to a TCP comunication change between win2000 and win xp or win 2003, so the problem could be a not "safer" net communication...

Thanks

lsc82
Posts: 16
Joined: Tue 28 Dec 2004 14:49
Location: Padova, Italy

Solution

Post by lsc82 » Tue 26 Apr 2005 16:58

I suppose that the code

Code: Select all

  
procedure TMySqlSession.Close;
[..]
  //FreeQuery; - optimization for FetchAll = False
  status := msReady;

does not work with mysql 4.1.10-11 or win xp or win 2003, and writing

Code: Select all

procedure TMySqlSession.Close;
[..]
  FreeQuery; // - optimization for FetchAll = False
  //status := msReady; - bad
I've make my work around. Perhaps the comunication is not accepted by mysql and the connection is not closed in mysql.

Is this the right solution?

Post Reply