TUniConnection freeze

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

TUniConnection freeze

Post by wjm4 » Thu 20 May 2010 19:12

I have an application that launches a thread that creates a uni connect and query, uses those to update the database then exits. There are mutliple threads created when an update needs to occur.

The problem is that when I stress test this software, the code will hang at the creation of the new connection object and not return. This makes my application hang and thus create a problem. My question is what would make my code freeze on the creation of the new object. I am not trying to connect or anything yet, just create it. Any suggestions? This code takes place in the constructor of the thread where sestmp is a template connection passed to the thread from the main form for the thread connections setup.

Code: Select all

 stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  CoInitialize(NULL); //Init Com Use
  TComponent * oldcomp = sestmp->Owner->FindComponent("CON"+IntToStr(ConNum));
  delete oldcomp;
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal)+":"+IntToStr(sestmp->Owner->ComponentCount)+":"+);
  [b]Ucon = new TUniConnection(sestmp->Owner);[/b]
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  Ucon->Name = "CON"+IntToStr(ConNum);
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  Ucon->ProviderName = sestmp->ProviderName;
  Ucon->Username = sestmp->Username;
  Ucon->Password = sestmp->Password;
  Ucon->Server = sestmp->Server;
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  Ucon->Database = sestmp->Database;
  Ucon->Pooling = sestmp->Pooling;
  Ucon->PoolingOptions = sestmp->PoolingOptions;
  Ucon->Options = sestmp->Options;
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  Ucon->LoginPrompt = false;
  stepVal++; LogToFile("MSG: "+IntToStr(stepVal));
  Ucon->Connect();
Thanks for the help

wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

Other Issues

Post by wjm4 » Fri 21 May 2010 02:46

Is there a reason that a the use of unidac components would cause a service application using threads to crash randomly? I have taken the components out of my service application and everything works fine. However, when I put them back in, the service application eventually crashes without exception thrown. I am catching all exceptions and writing them to file and there are not any thrown.
The basic code is as follows:

Code: Select all

1) Service Application Starts and Launches Server Thread
2) Server Thread loops and gets information from a queue and launches another thread to write that information to a log table in a sql server database
3) Update thread opens a TUniConnection and connects to the database
  3a) Then Creates a TUniQuery and prepares it.
  3b) Sets Parameters to the TUniQuery and executes it.
  3c) Thread Exits and deletes all objects including TUni
Any suggestions on how to troubleshoot the problem? Why do TUni Components cause a service application to crash without throwing an exception? I am assuming that it is throwing an access violation that can not be caught.

wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

Solution

Post by wjm4 » Mon 24 May 2010 19:55

I found my problem, It was in my code and not Unidac.

tobias_cd
Posts: 56
Joined: Thu 18 Dec 2008 22:10

Post by tobias_cd » Tue 25 May 2010 04:54

Hello,
since you use threads you could also run into locking issues depending on your use (especially UPDATEs). Was this the case?
Regards,
Tobias

wjm4
Posts: 72
Joined: Mon 12 Feb 2007 21:31

Post by wjm4 » Tue 25 May 2010 13:00

I was just inserting records and have not experienced any locking issues. Thanks for the response.

Post Reply