Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gbak: Incorrect total statistics for restore #8391

Closed
Noremos opened this issue Jan 16, 2025 · 6 comments
Closed

gbak: Incorrect total statistics for restore #8391

Noremos opened this issue Jan 16, 2025 · 6 comments

Comments

@Noremos
Copy link
Contributor

Noremos commented Jan 16, 2025

I restored a 74M database (~9401 pages), but the number of writes in the gbak output shows only 3087.

gbak -c -user SYSDBA ./mydb.fbk ./mydb.fdb -v -ST W
gbak: writes
gbak:      0 opened file ./mydb.fbk
gbak:      0 transportable backup -- data in XDR format
gbak:      0            backup file is compressed
gbak:      0 backup version is 11
gbak:    781 created database ./mydb.fdb, page_size 8192 bytes
gbak:      2 started transaction
gbak:      0 restoring domain RDB$1
gbak:      0 restoring domain RDB$2
...
gbak:     11 finishing, closing, and going home
gbak:   3087 total statistics
gbak:adjusting the ONLINE and FORCED WRITES flags

ll ./mydb.fdb
-rw-rw---- 1 art art 77012992 янв 15 12:59 ./mydb.fdb

77012992 / 8192 = 9401
9401 > 3087

The CCH logging clearly shows almost 10,000 writes

@pavel-zotov
Copy link

I can't reproduce original problem.
Consider following script (it is from another ticket, but i hope this no matters):

set bail on;
set list on;
set echo on;
shell if exist c:\temp\tmp4test.fdb del c:\temp\tmp4test.fdb;
create database 'c:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey' page_size 8192;
commit;
show version;
recreate sequence g;
recreate table test(id int, b blob);
set autoterm on;
execute block as
    declare n int;
begin
    insert into test(id, b) values(gen_id(g,1), gen_uuid());
    insert into test(id, b)
    values(
            gen_id(g,1)
            ,(select list(gen_uuid()) as s from rdb$types,rdb$types)
          );
 
    insert into test(id, b)
    values(
            gen_id(g,1)
            ,(select list(gen_uuid()) as s from (select 1 x from rdb$types,rdb$types,rdb$types rows 800000))
          );
end
;
commit;

Now let's do b/r using FB 6.0.0.594 (ServerMode = Super):

gbak -b -g c:\temp\tmp4test.fdb stdout | C:\FB\60SS\gbak -rep -v -st w stdin c:\temp\tmptest.restored.fdb 1>gh-8394.tmp.restore.6.0.0.594.log 2>&1

Log is:

gbak: writes
gbak:      0 transportable backup -- data in XDR format
gbak:      0         backup file is compressed
gbak:      0 backup version is 11
gbak:    781 created database c:\temp\tmptest.restored.fdb, page_size 8192 bytes
gbak:      2 started transaction
gbak:      0 restoring domain RDB$1
...
gbak:      9 finishing, closing, and going home
gbak:   3185 total statistics
gbak:adjusting the ONLINE and FORCED WRITES flags

Size of restored .fdb: 21610496
21610496 / 8192 = 2638.0 -- and this is less than in log of "gbak -st w"

PS. Used firebird.conf:

AuthServer = Srp, Win_Sspi, Legacy_Auth
BugCheckAbort = 1
ClearGTTAtRetaining = 0
ClientBatchBuffer = 131072
ConnectionIdleTimeout = 0
DefaultDBCachePages = 10K
ExtConnPoolLifeTime = 10
ExtConnPoolSize = 10
ExternalFileAccess = Full
InlineSortThreshold = 1000
IpcName = xnet_fb6x_ss
KeyHolderPlugin = fbSampleKeyHolder
MaxIdentifierByteLength = 252
MaxIdentifierCharLength = 63
MaxParallelWorkers = 8
MaxUnflushedWrites = -1
MaxUnflushedWriteTime = -1
ParallelWorkers = 2
ReadConsistency = 0
RemoteServicePort = 3600
ServerMode = Super
SnapshotsMemSize = 64K
StatementTimeout = 600
TempCacheLimit = 1G
TipCacheBlockSize = 4M
UseFileSystemCache = true
UserManager = Srp, Legacy_UserManager
WireCrypt = Enabled
WireCryptPlugin = ChaCha, Arc4

@Noremos
Copy link
Contributor Author

Noremos commented Jan 23, 2025

The issue has already been fixed. The latest affected version is 6.0.0.588.

@pavel-zotov
Copy link

But in 6.0.0.584 (15-jan-2025) above mentioned script gives similar result:

gbak: writes 
gbak:      0 transportable backup -- data in XDR format
gbak:      0 		backup file is compressed
gbak:      0 backup version is 11
gbak:    781 created database c:\temp\tmptest.restored.fdb, page_size 8192 bytes
...
gbak:      9 finishing, closing, and going home
gbak:   3165 total statistics
gbak:adjusting the ONLINE and FORCED WRITES flags

(vs "gbak: 3185 total statistics" in 6.0.0.594)

So: how to reproduce source problem (i.e. when restore log contains total statistics less than num of pages in FDB file) ?

@Noremos
Copy link
Contributor Author

Noremos commented Jan 23, 2025

I reproduced it on the EMPLOYEE databse with default configs. Here is the backup: https://drive.google.com/file/d/1fHg0Br1F7ZZc56ryHDoHpKQd-eppQPfV/view?usp=sharing

@Noremos
Copy link
Contributor Author

Noremos commented Jan 23, 2025

My bad, not EMPLOYEE. It is a TPCH database

@pavel-zotov
Copy link

It seems that value of DefaultDBCachePages can affect on outcome.
I have DefaultDBCachePages = 10K and this is greated than 77012992 / 8192 = 9401
When FB is running with such value of DefaultDBCachePages, i get in restore log "gbak: 9955 total statistics"
When DefaultDBCachePages = 5K then "gbak: 5625 total statistics", etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants