Random Error with PostgreSQL

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
chkaufmann
Posts: 82
Joined: Sat 01 Jul 2006 11:42

Random Error with PostgreSQL

Post by chkaufmann » Tue 13 Sep 2022 12:57

Hi,

since I update from UniDac 8.x to the latest UniDac version (9.2.1) I get a new error in different places. Unfortunately not always when I run the code only on some occations. So it's difficult to find out. Can somebody give me a hint about where I should start to search the problem. The error looks always like this:

Code: Select all

exception class          : EUniError
exception message        : Error on data writing to the connection: An existing connection was forcibly closed by the remote host. Socket Error Code: 10054($2746).

thread $3564 (TBackgroundTaskRunner):
00e77617 RankingsHttpService.exe Uni               1182 HandleInternalError
00e7bfe7 RankingsHttpService.exe Uni               3385 TCustomUniDataSet.OpenCursor
77a63a61 ntdll.dll                                      KiUserExceptionDispatcher
00480dd5 RankingsHttpService.exe madExcept         3136 IsValidObject2
004b9bc1 RankingsHttpService.exe madExcept        16620 SetLastExceptionHelper
004b9c26 RankingsHttpService.exe madExcept        16655 MyRaiseExceptProc
011a9cda RankingsHttpService.exe PgClassesUni      4999 TPgSQLConnection.ProcessInternalException
011b0294 RankingsHttpService.exe PgClassesUni      7768 TPgSQLCommand.InternalExecute
77a63a61 ntdll.dll                                      KiUserExceptionDispatcher
004b9bc1 RankingsHttpService.exe madExcept        16620 SetLastExceptionHelper
004b9c26 RankingsHttpService.exe madExcept        16655 MyRaiseExceptProc
01172ecc RankingsHttpService.exe PgSQLNetUni        287 TPgSQLNet.VioWrite
01172fab RankingsHttpService.exe PgSQLNetUni        324 TPgSQLNet.FlushSend
0116a4ff RankingsHttpService.exe PgSQLProtocolUni  1590 TPgSQLProtocol.Flush
0116b33c RankingsHttpService.exe PgSQLProtocolUni  1915 TPgSQLProtocol.InternalExecuteStmt
01169585 RankingsHttpService.exe PgSQLProtocolUni  1144 TPgSQLProtocol.ExecuteStmt
011b016e RankingsHttpService.exe PgClassesUni      7740 TPgSQLCommand.InternalExecute
011af019 RankingsHttpService.exe PgClassesUni      7174 TPgSQLCommand.Execute
011ab2e8 RankingsHttpService.exe PgClassesUni      5559 TPgSQLTransaction.ExecuteSQL
011ab40b RankingsHttpService.exe PgClassesUni      5599 TPgSQLTransaction.StartTransaction
011af6ef RankingsHttpService.exe PgClassesUni      7436 TPgSQLCommand.PrepareFetchConnection
011b18c2 RankingsHttpService.exe PgClassesUni      8354 TPgSQLRecordSet.ExecFetch
00e5844c RankingsHttpService.exe CRAccess          3955 TCRRecordSet.InternalOpen
011b368b RankingsHttpService.exe PgClassesUni      9244 TPgSQLRecordSet.InternalOpen
00d4ba98 RankingsHttpService.exe MemData           2584 TData.Open
00df2a3b RankingsHttpService.exe MemDS             1131 TMemDataSet.InternalOpen
00e28597 RankingsHttpService.exe DBAccess         11319 TCustomDADataSet.InternalOpen
00dde56e RankingsHttpService.exe Data.DB                TDataSet.DoInternalOpen
00dde61e RankingsHttpService.exe Data.DB                TDataSet.OpenCursor
00df2dae RankingsHttpService.exe MemDS             1263 TMemDataSet.OpenCursor
00e22635 RankingsHttpService.exe DBAccess          8748 TCustomDADataSet.OpenCursor
00e7bfd3 RankingsHttpService.exe Uni               3383 TCustomUniDataSet.OpenCursor
00dde4d1 RankingsHttpService.exe Data.DB                TDataSet.SetActive
00e22423 RankingsHttpService.exe DBAccess          8685 TCustomDADataSet.SetActive
00dde310 RankingsHttpService.exe Data.DB                TDataSet.Open
00f6e6e5 RankingsHttpService.exe BSDB              2159 TBSDBConnection.InternalOpenLookup
Christian

evgeniym
Devart Team
Posts: 103
Joined: Thu 13 May 2021 07:08

Re: Random Error with PostgreSQL

Post by evgeniym » Wed 14 Sep 2022 11:23

Hi Christian,
Thanks for contacting us!

Could you please update to the latest UniDAC 9.3.0 and see if the issue is reproduced?

You can download the latest version from our website via the following link: https://www.devart.com/unidac/download.html

In case if the issue will be reproducing, kindly create and send us sample which demonstrates described behavior and DDL scripts to create and fill-in database objects.

You can send a sample using the form on our website: https://devart.com/company/contactform.html

chkaufmann
Posts: 82
Joined: Sat 01 Jul 2006 11:42

Re: Random Error with PostgreSQL

Post by chkaufmann » Fri 16 Sep 2022 07:47

I still have the same error.

Code: Select all

exception class          : EUniError
exception message        : Error on data writing to the connection: An existing connection was forcibly closed by the remote host. Socket Error Code: 10054($2746).

thread $470 (TBackgroundTaskRunner):
00e779eb RankingsHttpService.exe Uni               1182 HandleInternalError
00e7c2e7 RankingsHttpService.exe Uni               3356 TCustomUniDataSet.Prepare
770d3a61 ntdll.dll                                      KiUserExceptionDispatcher
00480dd5 RankingsHttpService.exe madExcept         3136 IsValidObject2
004b9bc1 RankingsHttpService.exe madExcept        16620 SetLastExceptionHelper
004b9c26 RankingsHttpService.exe madExcept        16655 MyRaiseExceptProc
011aa7ce RankingsHttpService.exe PgClassesUni      5062 TPgSQLConnection.ProcessInternalException
011b0df0 RankingsHttpService.exe PgClassesUni      7841 TPgSQLCommand.InternalExecute
770d3a61 ntdll.dll                                      KiUserExceptionDispatcher
004b9bc1 RankingsHttpService.exe madExcept        16620 SetLastExceptionHelper
004b9c26 RankingsHttpService.exe madExcept        16655 MyRaiseExceptProc
01173598 RankingsHttpService.exe PgSQLNetUni        287 TPgSQLNet.VioWrite
01173677 RankingsHttpService.exe PgSQLNetUni        324 TPgSQLNet.FlushSend
0116abcb RankingsHttpService.exe PgSQLProtocolUni  1590 TPgSQLProtocol.Flush
0116ba08 RankingsHttpService.exe PgSQLProtocolUni  1915 TPgSQLProtocol.InternalExecuteStmt
01169c51 RankingsHttpService.exe PgSQLProtocolUni  1144 TPgSQLProtocol.ExecuteStmt
011b0cca RankingsHttpService.exe PgClassesUni      7813 TPgSQLCommand.InternalExecute
011afb49 RankingsHttpService.exe PgClassesUni      7242 TPgSQLCommand.Execute
011abddc RankingsHttpService.exe PgClassesUni      5622 TPgSQLTransaction.ExecuteSQL
011abeff RankingsHttpService.exe PgClassesUni      5662 TPgSQLTransaction.StartTransaction
011b0247 RankingsHttpService.exe PgClassesUni      7508 TPgSQLCommand.PrepareFetchConnection
011af96c RankingsHttpService.exe PgClassesUni      7177 TPgSQLCommand.Prepare
00e58884 RankingsHttpService.exe CRAccess          4040 TCRRecordSet.InternalPrepare
011b37b1 RankingsHttpService.exe PgClassesUni      9006 TPgSQLRecordSet.InternalPrepare
00d4b56b RankingsHttpService.exe MemData           2635 TData.Prepare
00e588aa RankingsHttpService.exe CRAccess          4051 TCRRecordSet.Prepare
011b25fb RankingsHttpService.exe PgClassesUni      8490 TPgSQLRecordSet.Prepare
00df294f RankingsHttpService.exe MemDS             1068 TMemDataSet.Prepare
00e22301 RankingsHttpService.exe DBAccess          8637 TCustomDADataSet.Prepare
00e7c2d3 RankingsHttpService.exe Uni               3354 TCustomUniDataSet.Prepare
00dfa43a RankingsHttpService.exe MemDS             5092 TMemDataSet.SetPrepared
00fb3f67 RankingsHttpService.exe BSDBUniDACImp      315 TBSUniDataSet.PrepareParams
It's almost impossible to create a reproducable case because it doesn't happen regularly. So I need a solution to isolate the problem in the production environement:
- It happens in an application, that runs on a server and that executes some tasks, e.g. every hour.
- It never happened before update from UniDac 8.6.x to version 9.x
- Normally all runs fine, but as soon as I make changes to the database with a different application, I start to have these errors
- Readonly access to the same database doesn't seem to have any influence. There are PHP scripts from a website running all the time.
- Currently I use PostgreSQL 13.x. Database and application are running on the same computer, so there is no router or firewall between them. I'm using Win Server 2019, all updates installed.
- The UniDac objects (TUniConnection, TUniDataset) are objects newly created in a new thread

So any hint on how to isolate the problem would be helpfull.

Christian

evgeniym
Devart Team
Posts: 103
Joined: Thu 13 May 2021 07:08

Re: Random Error with PostgreSQL

Post by evgeniym » Fri 16 Sep 2022 13:43

Hi Christian,
"An existing connection was forcibly closed by the remote host" means that the server closed the connection.
The reason could be:
1) Sending incorrect data to the server
2) Network problems
3) All system resources have been used
4) Application error

Please note, that without a sample that reproduces the issue we cannot name its cause.

Post Reply