--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/692328bd-c250-41de-8503-b9c12cb1ae67n%40googlegroups.com.
>> I would like to clarify the meaning of the term "Sharing the database
You really do not clarify it 😉 For me only fasible way to work with database is one computer with it and installed Firebird server which listen on some port (default 3050). And all clients in the network connect to db using that TCP port.
Your connection string should be e.g.
10.100.200.15/3050:D:\mydatabase.fdb
And it really should not be \\10.100.200.15\mydatabase.fdb.
Which one do you use?
>> Backing up and transferring the database file via email or a cloud storage system, is the only feasible way to physically transfer the data between these remote office locations
>> Regarding Moving the database between remote locations, it is impossible to "share" the data across long distance remote office locations,
Why? Vpn+RDP and even with only VPN (if db application is designed as thin client).
>> All I am trying to do is to detect this commonly occurring situation and warn the local user to disconnect from the database on all other networked workstations, prior to restore.
Is this db ReadOnly for users? If not, then you lost users work by replacing db.
And by detecting connected users. Simply connect to DB and send event to the users. But what then, do you replace db without copy of current one?
And Firebird do not allow you to replace db currently used by users as any other file opened in system.
To be absolutely sure that db is not used, simply rename database file. If succesfull, then noone is connected.
You can also look at database shutdown modes.
regards,
Karol Bieniaszewski
--
You can rename remote file by PS
https://www.reddit.com/r/PowerShell/comments/6u1wiz/rename_file_on_remote_pc_to_name_of_remote_pc/
You can choose also different way, not so elegant.
Connect to DB and run
DELETE FROM MON$ATTACHMENTS WHERE MON$SYSTEM_FLAG<>1 AND MON$USER<>CURRENT_USER.
I recommend to send first to users db event. And in app you must catch this event and monit users that they should finish their job in e.g. 3 minutes.
And after 3 minutes you can run this delete command. Add also shutdown mode to prevent new connection. All together will be more elegant.
I recommend also to send first email that such action will be e.g. at 8pm to 8:30pm. So users now that they should not work in this time.
regards,
Karol Bieniaszewski
Od: Dr Mariusz Skorupski
Wysłano: sobota, 12 grudnia 2020 12:32
Temat: RE: [firebird-support] How to detect if database is in use when restoring
Ważność: Wysoka
Bardzo dziekuje za odpowiedz i sugestje.
I will make further comments in English.
Yes, I use Firebird server set up in a correct way, as you have suggested below.
When restoring the database on a remote location computer, the old database is replaced with the new one. This is by design.
Users fully understand that restore will delete the old database. It is usually done on a computer that is using the database as read-only.
I have implemented your idea of trying to rename the database, to test if it is being used (connected to).
That works really well when the database renaming is done on the server (master) computer, i.e. the one connected locally to the database as
localhost:C:\mydatabase.fdb
Lets assume that this server computer name is XYZ and it has the database file stored in C:\mydatabase.fdb
I have written the code in RAD Studio (Delphi) that attempts to rename the C:\mydatabase.fdb to C:\mydatabase.fdb1.
If rename is successful, the database file is renamed back to the original name and the Restore is successfully processed.
If the database is in use (locked), i.e. is being accessed from the client computer (which uses the following access string XYZ:C:\mydatabase.fdb)
the renaming of the database file fails and the Restore process is cancelled with an appropriate error message.
Unfortunately, this database renaming test does not work properly when the Restore of the database is initiated from the client computer.
When trying to rename the database file stored remotely on the server computer, i.e. renaming XYZ:C:\mydatabase.fdb to XYZ:C:\mydatabase.fdb1
it always fails to rename it, irrespective if the database file is in use on the server computer, or not.
I haven’t found a solution to this second (file renaming) issue.
I have already implemented the GFIX -shut -force 0 command prior to GBAK -rep, however that does not seem to work correctly when the database is open on another workstation connected using the ServerMode = Super connection mode.
The GFIX -shut -force 0 command appears to only work when the ServerMode = Classic is used.
Note that users must be allowed to run the database Restore from either the server computer or from the workstation/client computer.
The Restore works fine when run from either end, as long as the database is not opened on the other computer.
If you have any other suggestions how to overcome this problem, or how to detect if the database is in use, or how to check (in code) for any existing external database connections, I would greatly appreciate your advice.
Z gory dziekuje za pomoc i serdecznie pozdrawiam
Mariusz
New Zealand
--
You received this message because you are subscribed to a topic in the Google Groups "firebird-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebird-support/QE7zcY-s-Cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/4Ct7wl4XlBzljBxM%40smtp.poczta.onet.pl.
I have now resolved this problem by implementing the solution suggested by Ertan (Thank you).I am using the following code (in Delphi RAD Studio) to identify the number of connected database users:with SQL_Select dobeginif Transaction.Active then Transaction.Commit;Transaction.StartTransaction;Clear;Add('SELECT COUNT(MON$ATTACHMENT_ID)');Add('FROM MON$ATTACHMENTS');Add('where MON$ATTACHMENT_ID <> CURRENT_CONNECTION');