Icon View Incident Report

Serious Serious
Reported By: Robert Cram/John Hay
Reported On: 1/14/2005
For: Version 4.16 Build 1
# 1944 Keeping the Server Window Open While Many Connections Are Being Made Can Cause a Server Lockup

I have just tried the following code with version 4.16 on a Pentium III 1Ghz 256MB Ram Windows 2000 SP4.

I ran the the code 5 or 6 times without any problem. I then "opened" the server window and after on the first run the server stopped responding. I could not log in anymore on either the standard or admin port. I tried it again with the server window closed and again no problem.

Next I logged in on an admin port and tried the same thing. After the server stopped responding I was still able to get the log from the admin client that was logged in.

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   Button2: TButton;
   procedure Button2Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

uses
 DBISAMtb;

var
 LastSessionValue: Integer;
 SessionNameSection: TRTLCriticalSection;

function GetNewSession: TDBISAMSession;
begin
 EnterCriticalSection(SessionNameSection);
 try
   LastSessionValue:=LastSessionValue+1;
   Result:=TDBISAMSession.Create(nil);
   Result.SessionName:='Serverextensions'+IntToStr(LastSessionValue);
 finally
   LeaveCriticalSection(SessionNameSection);
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 i: Integer;
 FDBISAMSession: TDBISAMSession;
begin
 Screen.Cursor := crHourGlass;
 i := 0;
 try
   try
     repeat
       Inc(i);
       FDBISAMSession := GetNewSession;
       FDBISAMSession.SessionType := stRemote;
       FDBISAMSession.RemoteCompression := 0;
       FDBISAMSession.RemoteHost := '127.0.0.1';
       FDBISAMSession.RemotePort := 12005;
       FDBISAMSession.RemoteUser:= 'admin';
       FDBISAMSession.RemotePassword := 'DBAdmin';
       FDBISAMSession.Open;
       FDBISAMSession.Close;
       FreeAndNil(FDBISAMSession);
     until i=1000;
   finally
     Screen.Cursor := crDefault;
   end;
 except
   ShowMessage('Error in iteration '+IntToStr(i));
   raise;
 end;

end;

initialization
 LastSessionValue:=0;
 InitializeCriticalSection(SessionNameSection);
finalization
 DeleteCriticalSection(SessionNameSection);
end.



Comments Comments
The original report and code was from Robert Cram while John Hay followed up with the specifics regarding the server window.

The problem was that an internal synchronize call for display purposes was being made while a critical section was acquired internally in the engine by the session thread. The synchronize then caused timer messages to be processed, and these timer messages would sometimes try to acquire the (via the main thread) same critical section as that which was already acquired by the sesson thread. This would cause a lockup. The entire internal connection handling has been modified in the dbsrvr project to allow for a message pump that both avoids the use of the TThread.Synchronize method call and also allows for much faster connects and disconnects that aren't slowed down by the redrawing of the list view.


Resolution Resolution
Fixed Problem on 1/16/2004 in version 4.17 build 1
Image