Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 30 of 31 total
Thread HOT BACKUP LOCK ISSUES - Please Advise
Fri, Feb 23 2024 11:55 AMPermanent Link

Terry Swiers


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

Great.  Now you need to make sure that the database isn't opened anywhere.

Open up EDB Manager and establish a connection to the server.  In your IDE, set a breakpoint on the restore function and run it up to the line where you do the restore.  Jump back to EDB Manager and run the following query from the session level of your connection:

select * from configuration.serversessionlocks where objecttype = 'Database'

Do you see any records returned?
Mon, Feb 26 2024 3:16 PMPermanent Link

Andrew Hill

Terry, results before closing and after closing (then of course I closed EDBMgr - still LOCK ISSUE ?



Attachments: BeforeClosing.jpg
Tue, Feb 27 2024 2:51 PMPermanent Link

Terry Swiers

Hi Andrew,

> Terry, results before closing and after closing (then of course I closed EDBMgr - still LOCK ISSUE ?

Only the BeforeClosing attachment was present, which showed two locks on the database, so I don't know what the number of rows are after closing the session.

Set a breakpoint on the AppEngine.Open line of code and run the application to the breakpoint.   Open EDB Manager and open a session to the server engine, but do NOT open the database.  Run the server lock query.   It should return ZERO rows.  

Step through SrvSession.Open and then rerun the lock query. It should return zero rows. If it shows any rows, you have an event somewhere that is opening the database, which in turn is preventing the restore.
Tue, Feb 27 2024 8:36 PMPermanent Link

Andrew Hill

Terry, The ElevateDB Website went down and has only just come back up so here is the other image after closing that I was unable to post.

Obviously everything in my code is closed including EDBMgr but I still have Lock issue.



Attachments: ClosedServerModuleSessions.jpg
Tue, Feb 27 2024 8:41 PMPermanent Link

Terry Swiers


> Obviously everything in my code is closed including EDBMgr but I still have Lock issue.

At the point of the image that you sent, yes I agree that everything is closed.   Step over the next two lines and send a screenshot of EDB Manager with the results of the serversessionlocks query that I posted earlier.
Wed, Feb 28 2024 4:55 PMPermanent Link

Andrew Hill

After Engine & Database Opened.



Attachments: EngineDatabaseReOpened.jpg
Wed, Feb 28 2024 4:56 PMPermanent Link

Andrew Hill

After Restore Attempt



Attachments: AfterRestoreAttempt.jpg
Wed, Feb 28 2024 5:59 PMPermanent Link

Terry Swiers

From what I can see, you have something in your code that is opening the database when you make the server session connection.  Performing the restore, or attempting it, on it's own won't open the database so you have two options....

1. Track down the code that is opening the database when you open the session and disable it temporarily when you want to do a restore.

2. Create a new TEDBSession object, manually assign the required connection information (host, port, etc....), open that session and do the restore from that temporary session.  After the restore is complete, delete the temporary session and re-open the SrvSession object.
Wed, Feb 28 2024 9:25 PMPermanent Link

Andrew Hill

Terry, what you are seeing is my Database being ReOpened after Lock FAIL.

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

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

   TwentyFourHourTimer.Enabled:= False;
   //
   SrvDatabase.CloseDataSets;
   SrvDatabase.Close;
   //
   SrvSession.DropConnections;
   SrvSession.Close;
   //
   AppEngine.Close;
   //
   AppEngine.Open;
   SrvSession.Open;

   ////////////////////////////////////////////////////////////////////////////
   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;
 TwentyFourHourTimer.Enabled:= True;

end;
Thu, Feb 29 2024 12:18 AMPermanent Link

Terry Swiers


> what you are seeing is my Database being ReOpened after Lock FAIL.

Attempting a restore that fails will NOT open the database.    Try the following:  This is untested, but should avoid any events that you have configured for the session that might be opening the database.

function TUniServerModule.RestoreDatabase(UserName: String): Boolean;

 function DoRestore( Source : TEDBSession) : Boolean;
 var
 lSession : TEDBSession;
 begin
 Result := False;
 Source.FreeCachedSQLStmts('');
 Source.FreeCachedFuncProcs('');
 Source.Close;
 lSession := TEDBSession.Create(nil);
 lSession.SessionType := Source.SessionType;
 case lSession.SessionType of
   stLocal: begin
     lSession.LocalConfigPath := Source.LocalConfigPath;
     lSession.LocalConfigName := Source.LocalConfigName;
     end;
   stRemote: begin
     lSession.RemoteHost := Source.RemoteHost;
     lSession.RemoteAddress := Source.RemoteAddress;
     lSession.RemotePort := Source.RemotePort;
     lSession.LoginUser := Source.LoginUser;
     lSession.LoginPassword := Source.LoginPassword;
     end;
   end;
 try  
 lSession.Execute('RESTORE DATABASE '+ProjectName+' '+
                       'FROM "'+RestoreBackupName+'" '+
                       'IN STORE "'+ProjectName+'-BK" '+
                       'INCLUDE CATALOG ;');  
 Result := True;
 except
 end;  
 lSession.Free;
 end;

begin
 Result:= False;

   TwentyFourHourTimer.Enabled:= False;
   SrvDatabase.Close;
   SrvSession.Close;
   AppEngine.Close;
   AppEngine.Open;

 Result := DoRestore(SrvSession);

 //////////////////////////////////////////////////////////////////////////////
 SrvSession.Open;
 SrvDatabase.Open;
 TwentyFourHourTimer.Enabled:= True;

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