firebird icon indicating copy to clipboard operation
firebird copied to clipboard

First query always fail on renamed db when shadow is enabled

Open medvedo opened this issue 5 months ago • 2 comments

We are migrating from 2.5 to 5 and found this problem:

When name unchanged, all works as expected:

# echo "create shadow 1 manual '/mnt/backup/db_shadow/billing_shadow_test.fdb';" | isql-fb5 test.fdb
# echo "select count(*) from abonents;" | isql-fb5 test.fdb
                COUNT 
===================== 
                    6

But if we rename file (for maintenteance purposes), strange things are appears at first query:

# echo "drop shadow 1 ;" | isql-fb5 test.fdb
# mv test.fdb test-in-maintenance.fdb
# echo "create shadow 1 manual '/mnt/backup/db_shadow/billing_shadow_test.fdb';" | isql-fb5 test-in-maintenance.fdb 
# mv test-in-maintenance.fdb test.fdb
# echo "select count(*) from abonents;" | isql-fb5 test.fdb
Statement failed, SQLSTATE = 08001
I/O error during "open" operation for file "/mnt/var/root/DB/TT/test-in-maintenance.fdb"
-Error while trying to open file
-No such file or directory
Use CONNECT or CREATE DATABASE to specify a database
Use CONNECT or CREATE DATABASE to specify a database
# echo "select count(*) from abonents;" | isql-fb5 test.fdb
                COUNT 
===================== 
                    6

In SS mode, this bug is reproduced unclearly (may be single error as above, may be persistent error, may be all right), but it have significant side effect: settings in databases.conf not applied to database until daemon is restarted.

The error seems to appear more often in large databases: isql quickly returns some kind of open or write error, but the file is created and allocated (available space and permissions have been checked, of course), and db becomes unavailable until gfix -k

I/O error during "write" operation for file "/mnt/backup/db_shadow/billing_shadow.fdb"
        Error while trying to write to file
        Invalid argument

Some people think that shadow feature is not relevant at all, but when using SSD it is relevant again (especially for the first half of the joke about admins and backups).

medvedo avatar Jul 02 '25 08:07 medvedo

It's prohibited to perform file-level operations with databases when server process is running.

AlexPeshkoff avatar Jul 02 '25 10:07 AlexPeshkoff

Of course. But if the daemon is stopped, the problem still occurs: first query always fails

medvedo avatar Jul 02 '25 11:07 medvedo