Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Backup "remote" server
Mon, Jun 18 2012 12:53 AMPermanent Link

Mathias Burbach

Hello Folks!

I am fairly new to DBISAM. I want to backup a database on a "remote" server. Actually the backup tool shall run as a scheduled task, connect to the "remote" server on RemoteAddress 127.0.0.1 and do the backup. In the documentation for TDBISAMDatabase.Backup it says:

"The Backup method cannot be run when a transaction is currently active for the database. You can
inspect the InTransaction property to determine if a transaction is currently active for the database. When the backup executes, it obtains a read lock for the entire database that prevents any sessions from performing any writes to any of the tables in the database until the backup completes."

I tried to accommodate this by asking for any active transaction:

procedure TdmoMain.BackupDB;
var
 sBackupName: string;
 stlTablesToBackup: TStrings;
 iAttemptNo: Word;
begin
 sBackupName := Format('%s\%s\%s.bkp', [FBackupBaseDirectory, FormatDateTime('YYYY-MM', Date),
       FormatDateTime('DDHHNNSS', Now)]);
 ForceDirectories(ExtractFileDir(sBackupName));
 stlTablesToBackup := TStringList.Create;
 try
   dbsTest.Open;
   try
     dbsTest.Session.GetTableNames(dbsTest.DatabaseName, stlTablesToBackup);
     iAttemptNo := 0;
     while (iAttemptNo < FNumberOfAttempts) do begin
       if dbsAIMS.InTransaction then begin
         Sleep(FWaitSecondsBetweenAttempts * 1000);
         Inc(iAttemptNo);
       end else begin
         dbsTest.Backup(sBackupName, EmptyStr, FCompressionMode, stlTablesToBackup);
         iAttemptNo := FNumberOfAttempts;
       end;
     end;
   finally
     dbsTest.Close;
   end;
 finally
   stlTablesToBackup.Free;
 end;
end;

If I have another transaction open on that server - let's say in Database System Utility - it doesn't detect that open transaction and proceeds to try a backup. But then, when the Backup method is called, it will wait until the last transaction has been closed on that particular server before it can create the read lock for the entire DB. There is no exception and I can't seem to find a setting to set a timeout value for the wait period until a read lock can be created.

How should I avoid a backup call that will wait indefinitely?

Thanks for a short answer in advance.

Salut,
 Mathias
Tue, Jun 19 2012 6:22 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Mathias

I will assume you are not using restrictive transaction (only a few tables
and not the entire database).

Just try to open one table exclusivelly. If it fails, another process/user
is using it.

Eduardo

Image