Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Exception out of thread??
Mon, Oct 4 2021 1:40 AMPermanent Link

Ian Branch

Avatar

Hi Team,
I have the following code..
{code}
   //
   Thread := TThread.CreateAnonymousThread(
     procedure
     begin
       //
       DBSBackup.Execute('My database Backup SQL'" TO STORE "Backups" COMPRESSION 9 INCLUDE CATALOG');
       //
     end);
   try
     Thread.FreeOnTerminate := False;
     H := Thread.Handle;
     Thread.Start;
     while MsgWaitForMultipleObjects(1, H, False, INFINITE, QS_ALLINPUT) = (WAIT_OBJECT_0 + 1) do
       Application.ProcessMessages;
   finally
     FreeAndNil(Thread);
   end;
   //
{code}
I discovered that the backup was taking longer than the RemoteTimeout in TEDBSession.
I discovered it because I commented out the Thread stuff and ad EDB 1101 error appeared.
Changing the default RemoteTimeOut from 300 to 600 mitigated the issue but I would rather the error had surfaced from  the Thread.
Is there any way to make this happen??

Regards & TIA,
Ian
Mon, Oct 4 2021 2:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


Not an answer to your question but I would recommend running a backup as a job and choose a time when the system is either not used or lightly used.

Roy Lambert
Mon, Oct 4 2021 5:41 PMPermanent Link

Ian Branch

Avatar

Hi Roy,
In fact the Daily Backup is done via a Job and at 0400.
This utility is intended to be used just prior to and just after the Customer does a database Archive where multiple records from multiple tables are moved from 'Live' tables to 'Archive' tables.

I also use it if/when I do a structure change due to a Customer's request.

Ian
Mon, Oct 4 2021 6:40 PMPermanent Link

Raul

Team Elevate Team Elevate

On 10/4/2021 1:40 AM, Ian Branch wrote:
> I have the following code..
> {code}
>      //
>      Thread := TThread.CreateAnonymousThread(
>        procedure
>        begin
>          //
>          DBSBackup.Execute('My database Backup SQL'" TO STORE "Backups" COMPRESSION 9 INCLUDE CATALOG');
>          //
>        end);
>      try
>        Thread.FreeOnTerminate := False;
>        H := Thread.Handle;
>        Thread.Start;
>        while MsgWaitForMultipleObjects(1, H, False, INFINITE, QS_ALLINPUT) = (WAIT_OBJECT_0 + 1) do
>          Application.ProcessMessages;
>      finally
>        FreeAndNil(Thread);
>      end;
>      //
> {code}

This does not look to be thread safe - what is DBSBackup and where is it
created ?

See
https://www.elevatesoft.com/manual?action=viewtopic&id=edb2&product=rsdelphiwin32&version=11&topic=Multi_Threaded_Applications


> Changing the default RemoteTimeOut from 300 to 600 mitigated the issue but I would rather the error had surfaced from  the Thread.
> Is there any way to make this happen??

You can handle the OnRemoteTimeout event

https://www.elevatesoft.com/manual?action=viewevent&id=edb2&product=rsdelphiwin32&version=11&comp=TEDBSession&event=OnRemoteTimeout

Raul
Tue, Oct 5 2021 1:34 AMPermanent Link

Ian Branch

Avatar

Raul wrote:
>>This does not look to be thread safe - what is DBSBackup and where is it
created ?

IB - DBSBackup is an EDBSession Component on the form.

>>See
>>https://www.elevatesoft.com/manual?action=viewtopic&id=edb2&product=rsdelphiwin32&version=11&topic=Multi_Threaded_Applications

IB - Noted.

>>You can handle the OnRemoteTimeout event

>>https://www.elevatesoft.com/manual?action=viewevent&id=edb2&product=rsdelphiwin32&version=11&comp=TEDBSession&event=OnRemoteTimeout


IB - Noted.

Regards & Tks,
Ian
Tue, Oct 5 2021 2:55 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Ian


In that case make it a foreground job. The idea of a thread is to leave the main application responsive and for what you are describing I, personally, do not think that's a good idea. Ideally you do not want activity when running a backup.


Roy Lambert
Tue, Oct 5 2021 11:28 AMPermanent Link

Terry Swiers

In addition to what Roy said, I would also suggest dropping the compression level from 9 down to 6 or 7.  While your compression rate will depend on what is in the data, we saw the backup times cut in half with only about a 5% increase in the size of the backup when we changed our compression level from 9 down to 6.

This will make it a lot less painful to the end user if you do end up pushing this into the main thread.

Terry
Image