|
Holger Klemt made changes - 08/Oct/15 09:53 PM
Holger Klemt made changes - 08/Oct/15 09:58 PM
Alexander Peshkov made changes - 09/Oct/15 12:42 PM
Alexander Peshkov made changes - 09/Oct/15 01:34 PM
From the syntax POV, I'd rather suggest [PRESERVE FILE] or [{PRESERVE | DELETE} FILE].
+1 for Dmitry syntax.
[{PRESERVE | DELETE} FILE] is great
will do I've used many times following trivial .sh for making "hot-copy" of database with size moire than 30 Gb at 20-30 seconds:
fbhome=/opt/fb30sc dbn=oltp30 dbc=./$dbn.copy_$(date +'%Y%m%d_%H%M%S').fdb $fbhome/bin/nbackup -L ./$dbn.fdb cp ./$dbn.fdb $dbc $fbhome/bin/nbackup -N ./$dbn.fdb $fbhome/bin/nbackup -F $dbc $fbhome/bin/gstat -h $dbc No shadow required, no intermediate storage as ram-disk ('scp' can be used instead 'cp' to copy on remote host). So, what's the profit of create shadow & dropping it then ?
Pavel Zotov made changes - 12/Oct/15 11:17 AM
Do you think that will be good to have system option like
CREATE DATABASE DUMP FILE_NAME; and this create this shadow and drop it immediately without deleting file This is simpler and show the "new way" to backup database Karol, that's possibly good, but you've selected a bad place for discussing new feature - too few people read resolved tickets.
Devel list would be much better. I've found strange "persistent link" from ex-shadow file to its ex-root database, even when .sql script contain DROP SHADOW + COMMIT + RE-CONNECT.
Test files are in attached "core4955-ex_shadow-file-remains-in-shutdown.zip". Scenario: Window-1. Creates database and table with varchar indexed field and starts to fill it, thus doing "heavy DML" Window-2. 1) Launches .sql script which creates shadow file and immediatelly drops it with PRESERVE FILE clause. Then makes COMMIT. 2) After returning from .sql on step "1" - runs batch which: 2.1) obtains header attributes from shadow file; this is marked as "point 0" 2.2) moves .fdb to OFFLINE (am I right that at this moment .fdb should NOT affect in any was to the SHADOW theat was created before but then DROPPED ?) 2.3) checks that .fdb is really in shutdown mode (again reading attributes from database header) 2.4) again obtains header attributes from .SHD-file; this is marked as "point 1" 2.5) returns .fdb to ONLINE 2.6) checks that .fdb was really returned to ONLINE mode 2.7) attempts to activate shadow (or maybe properly now to say: "EX-shadow" ?) file. It should remove 'active shadow' from attributes. 2.8) obtains header attributes from shadow file; this is marked as "point 2" The first surprise is waiting on the "2.4", when we already moved .FDB to offline and now are verifying attributes of .SHD file: it appeared also in OFFLINE state. Why this ex-shadow "watches" for our handles with its ex-root ? Second surprise is on "2.7": ex-shadow file will be remained in OFFLINE state and we'll get error === database C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.SHD shutdown -Some database(s) were shutdown when trying to read mapping data === To reproduce unpack attached .zip and: 1) open "c4955-1.sql" and change path and name of database and shadow files: === shell del C:\MIX\firebird\QA\fbt-repo\tmp\c4955.fdb 2>nul; shell del C:\MIX\firebird\QA\fbt-repo\tmp\c4955.shd 2>nul; create database '/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4955.fdb'; === 2) open "c4955-1.sql" and change path and file of .db file: === . . . drop shadow 1 preserve file; commit; connect '/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4955.fdb' user 'SYSDBA' password 'masterke'; . . . === 3) open "c4955-2.bat" and change these settings: === set usr=sysdba set pwd=masterke set host=localhost set port=3333 set dbnm=c4955 === 4) launch in 1st winfow: isql -q -i c4955-1.sql It will issue smth like this: ISQL Version: WI-V3.0.0.32272 Firebird 3.0 Release Candidate 2 Server version: Firebird/Windows/Intel/i386 (access method), version "WI-V3.0.0.32272 Fi . . . Database: /3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4955.fdb MSG Attach_1. Starting "heavy DML"... 5) After 4-5 seconds open one else window and run there c4955-2.bat Check content of c4955-2.log, it should be like this: ##### Starting ISQL with create and drop shadow... MSG Attach_2. Check state of Attach_1: OK. It works, gen_id=20203 MSG Attach-2. RDB$FILES before dropping shadow FILE_NAME <null> FILE_SEQ <null> . . . drop shadow 1 preserve file; commit; connect '/3333:C:\MIX\firebird\QA\fbt-repo\tmp\c4955.fdb' user 'SYSDBA' password 'masterke'; set echo off; MSG Attach_2. RDB$FILES after dropping shadow FILE_NAME <null> FILE_SEQ <null> . . . Obtain header from .SHD file, point 0. Database "C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.SHD" Attributes force write, active shadow Root file name: C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.FDB Move .FDB to SHUTDOWN... Check header of.FDB file: whether it's in SHUTDOWN ? Database "C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.FDB" Attributes force write, full shutdown Obtain header from .SHD file, point 1. Database "C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.SHD" Attributes force write, active shadow, full shutdown Root file name: C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.FDB Return .FDB to ONLINE... Check header of.FDB file: whether it's in ONLINE ? Attributes force write Activate SHADOW file. This should remove 'active shadow' from attributes. STDERR: database C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.SHD shutdown STDERR: -Some database(s) were shutdown when trying to read mapping data Obtain header from .SHD file, point 2. Database "C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.SHD" Attributes force write, full shutdown Root file name: C:\MIX\FIREBIRD\QA\FBT-REPO\TMP\C4955.FDB
Pavel Zotov made changes - 14/Jan/16 02:04 PM
Pavel, Are you suggesting/saying that this case should be re-opened?
No. Because command 'drop shadow preserve file' does work: it really allows to create shadow file and use it. But this shadow is still 'watched' by its ex-root, I don't know why :-) May be something like 'postfix' one need to be implemented for this ticket ?.. |
drop shadow <N> no file delete;
or
drop shadow <N> no delete file;
being not sure which form is better I've decided to have both.
In 2.5 it's definitely unreal.
Must say that it was a matter of days for such interesting suggestion to get or not to get into v.3 - after RC1 which is coming very soon nobody will add even simple features. Please try not to be so late in the future.