Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 20 of 31 total
Thread HOT BACKUP LOCK ISSUES - Please Advise
Sun, Feb 18 2024 4:19 AMPermanent Link

Andrew Hill

OK, tried this - still fails - please advise - Thanks.

 //////////////////////////////////////////////////////////////////////////////
 try
   Result:= False;

   ////////////////////////////////////////////////////////////////////////////
   SrvDatabase.CloseDataSets;
   SrvDatabase.Close;

   //////////////////////////////////////////////////////////////////////////////
   SrvSession.Execute('RESTORE DATABASE '+ProjectName+' '+
                      'FROM "'+RestoreBackupName+'" '+
                      'IN STORE "'+ProjectName+'-BK" '+
                      'INCLUDE CATALOG ;');
   Result:= True;

 except
   on E: Exception do begin
     s:= E.Message;
   end;
 end;

 //////////////////////////////////////////////////////////////////////////////
 SrvDatabase.Open;
Mon, Feb 19 2024 1:48 PMPermanent Link

Andrew Hill

Still cannot get Restore to work even with Session.Execute - still cannot lock - Please advise
Mon, Feb 19 2024 11:30 PMPermanent Link

Terry Swiers

I don't know what the architecture is of your server, so I'm just going to throw some things out for you to look into.

First I'll just reiterate that the database that you are attempting to restore cannot be open ANYWHERE.  You MUST have exclusive access to the file via the session that is doing the restore because it has to replace the catalog and other associated files.   With that said....

1.  If your server creates a new database connection for each user, all of those connections must be closed before you attempt the restore.

2. If you are using SQL statement or procedure caching, make sure that you flush the caches for the session before you attempt to do the restore.   Better yet, close the session and reopen it again before you do the restore.   And this might apply to the user connection sessions as well.

3. If you are using a client/server connection and are running jobs against the database.  Make 100% sure that all of the jobs eventually call an empty USE statement as part of a finally statement to make sure that you close any connections to the database made in the jobs.

4. Make sure that you are using the latest version of EDB.   There were a few issues that were fixed recently with regards to locks not being released.

Hope this helps.
Tue, Feb 20 2024 10:18 PMPermanent Link

Andrew Hill

Terry, I am at my wits end ?

Updated to B2 (D12-2-38-B2) from B1

Local Database & Local Session has been Shutdown before this function is called.

function TUniServerModule.RestoreDatabase(UserName: String): Boolean;
var
 s: String;
begin

 Result:= False;

 //////////////////////////////////////////////////////////////////////////////
 try
   SrvDatabase.CloseDataSets;
   SrvDatabase.Close;
   //
   SrvSession.DropConnections;
   SrvSession.Close;
   //
   AppEngine.Close;
   //
   AppEngine.Open;
   SrvSession.Open;

   ////////////////////////////////////////////////////////////////////////////
   SrvSession.Execute('RESTORE DATABASE "CASHBOOK" '+
                      'FROM "CASHBOOK-2024-02-19.EDBBkp" '+
                      'IN STORE "CASHBOOK-BK" '+
                      'INCLUDE CATALOG ;');

   ////////////////////////////////////////////////////////////////////////////
   Result:= True;

 except
   on E: Exception do begin
     s:= E.Message;
   end;
 end;

 //////////////////////////////////////////////////////////////////////////////
 SrvDatabase.Open;

end;
Tue, Feb 20 2024 11:10 PMPermanent Link

Terry Swiers

Hi Andrew,

> Terry, I am at my wits end ?

Trust me, I know what that's like.  I ran into the same issues with our application with regards to restores as well as repairing and optimizing tables.  

> Local Database & Local Session has been Shutdown before this function is called.

You mentioned a global session.  Have you closed that as well?

I know that this may sound drastic, but have you thought about taking your app and making all of your connections client/server, at least in your development environment.  What this buys you is the ability to use EDB Manager to view the server sessions and the server session locks.   That gives you the ability to see which connections still have locks on the database you are trying to restore, especially if you give them a unique traceable description for the connection to the server.
Wed, Feb 21 2024 1:22 AMPermanent Link

Andrew Hill

Terry, that is a very good idea, I have already programed Remote and Local into the app so it is just a matter of setting a flag.

My previous dialog was based on stLocal with my Server section holding the Engine and my Local section having it's own Database and Session code .

Will advise ...
Thu, Feb 22 2024 9:30 PMPermanent Link

Andrew Hill

ALL Sessions Closed



Attachments: ClosedServerModuleSessions.jpg
Thu, Feb 22 2024 9:31 PMPermanent Link

Andrew Hill

Server Session Opened For Restore.

Still Have Lock Issues



Attachments: OpenServerModule SessionOnly.jpg
Thu, Feb 22 2024 9:36 PMPermanent Link

Andrew Hill

As you can see, ALL Sessions Were Closed and EDBSVR reflected accordingly.

Then, ONLY my ServerModule Opened the Engine and Session (no local module connections at this stage) then requesting Restore, FAILS claiming Lock Issue.
Thu, Feb 22 2024 9:53 PMPermanent Link

Raul

Team Elevate Team Elevate

<<
Andrew Hill wrote:

As you can see, ALL Sessions Were Closed and EDBSVR reflected accordingly.

Then, ONLY my ServerModule Opened the Engine and Session (no local module connections at this stage) then requesting Restore, FAILS claiming Lock Issue.
>>

Late to the thread here and this might have already been done (apologies in that case) but as a sanity check can you confirm "SrvSession.DatabaseCount" = 0 before running restore sql ?

Only to ensure no nothing was auto-created when session opened.

If it is 0 then there is either a local session (i know you said there are none) or possibly check for read/write issues with any temp folders (this is a total guess territory though).

Raul
« Previous PagePage 2 of 4Next Page »
Jump to Page:  1 2 3 4
Image