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
Index corruption when add data in long-key-indexed field [CORE4904] #5196
Comments
Modified by: @hvladassignee: Vlad Khorsun [ hvlad ] |
Modified by: @hvladVersion: 3.0 Beta 2 [ 10586 ] Version: 2.5.4 [ 10585 ] Fix Version: 3.0 RC 1 [ 10584 ] Fix Version: 2.5.5 [ 10670 ] Version: 3.0 RC 1 [ 10584 ] => |
Commented by: @hvlad The bug is in index delete node code. Jump nodes were updated wrongly and some index keys could |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Commented by: @pavel-zotov Index depth = 17 - is it considered as invalid now ?
|
Commented by: @hvlad > Index depth = 17 - is it considered as invalid now ? |
Commented by: @pavel-zotov I see that 'gstat -r' output contains "footsteps" of statement which tried to create index with extremely high depth (and thus was not completed). === recreate sequence g; show table test; set list on; select 'Starting inserts' as msg, current_timestamp from rdb$database; set term ^; select 'Finish inserts' as msg, current_timestamp from rdb$database; show sequence g;Output will be like this:S VARCHAR(1014) Nullable MSG Starting inserts Statement failed, SQLSTATE = 54000 MSG Finish inserts Generator G, current value: 109, initial value: 0, increment: 1 ----------- value of sequence can differ but will be about thisAnd this is sample of "gstat -r" output:TEST (128)
=== One may see that despite that INSERTs were declined, we have index depth = 16 and leaf buckets = 103. WHy "gstat -r" report contain such value for index which in fact is empty ? |
Commented by: @hvlad > One may see that despite that INSERTs were declined, we have index depth = 16 and leaf buckets = 103. > After sweep this value remains the same. Validation doesn`t show any errors on this database. > WHy "gstat -r" report contain such value for index which in fact is empty ? Obviously we have some issue with index GC algorithm. It doesn't show itself in "real life", btw. |
Commented by: @pavel-zotov I will create new ticket a little later, but can comment strange (IMO) fact that when index key length is about max. implementation limit than number of records that can be inserted is reduced very fast ? For page_size = 4096 I've found that Difference in 'capacity' is more than 15x when just adding one byte to index key, while this is not absolute limit for this page_size (1015). |
Commented by: @pavel-zotov > If you wish you may create new ticket for it. |
Commented by: @hvlad Pavel, ticket you created is completely wrong. There is no error in gstat. There is an issue in index code. |
Modified by: @pavel-zotovstatus: Closed [ 6 ] => Closed [ 6 ] QA Status: No test => Done successfully Test Details: In order to check ticket issues this test does following: Checked on WI-V3.0.0.32140 (CS, SC); WI-V3.0.0.32157 - official RC1 (SS) |
Submitted by: @pavel-zotov
Relate to CORE4914
Config:
Servermode = SuperClassic
RemoteServicePort = 3330
DefaultDbCachePages = 512
BugCheckAbort=1
AuthClient = Legacy_Auth,Srp,Win_Sspi
AuthServer = Legacy_Auth,Srp
UserManager = Legacy_UserManager
WireCrypt = Disabled
FileSystemCacheThreshold = 65536K
LockMemSize = 64M
LockHashSlots = 22111
MaxUserTraceLogSize = 99999
TempCacheLimit = 2147483647
TempDirectories = /tmp/firebird
Create new database, make its FW = OFF and set sweep interval = 100 (one hundred).
Run ISQL so that it will show prompt (i.e. do NOT add '-i <file.sql>' in its command line).
Then do:
SQL> in file.sql;
-- and wait until it finish. After finish do not continue in this window "commit / rollback" and do not close it.
file.sql:
===
recreate sequence g;
recreate table fix(id int primary key, s varchar(1000) unique);
insert into fix
select row_number()over(), rpad('', 1000, uuid_to_char(gen_uuid()))
from rdb$types,(select 1 i from rdb$types rows 10) rows 1000;
commit;
insert into fix
select row_number()over(), rpad('', 1000, uuid_to_char(gen_uuid()))
from rdb$types,(select 1 i from rdb$types rows 10) rows 1000;
set list on;
select 'Started at '||current_time msg from rdb$database;
select * from mon$database;
set term ^;
execute block as
declare n int = 500;
begin
while (n>0) do
begin
in autonomous transaction do
execute statement '
merge into fix t
using (
select row_number()over() id, rpad('''', 1000, uuid_to_char(gen_uuid())) s
from rdb$types,(select 1 i from rdb$types rows 10) rows 1000
) s on http://t.id = http://s.id
when matched then update set t.s = s.s
'
;
n = n - 1 + 0*gen_id(g,1);
end
end
^
set term ;^
select 'Done at '||current_time msg from rdb$database;
After ISQL show 'Done at ...' and returns to prompt, create another window and move database into shutdown state: gfix -shut full -force 0 <database.fdb>
Then return .fdb to ONLINE and make re-connect in ISQL. It will force sweep to start.
After this sweep will finish, run validation using FBSVCMGR:
fbsvcmgr host/port:service_mgr user sysdba password masterkey action_validate dbname <database.fdb>
On LI-V3.0.0.31942 (build of 28-29 july 2015) I got every time on this step:
Index 2 is corrupt on page 21580 level 0 at offset 5100. File: /opt/fb30snap/src/jrd/validation.cpp, line: 2052
Commits: a74a9d4 00d91aa 0e33ef9 a59b64d FirebirdSQL/fbt-repository@a588c5d FirebirdSQL/fbt-repository@f6f8852 FirebirdSQL/fbt-repository@315087c FirebirdSQL/fbt-repository@d782b1a
====== Test Details ======
In order to check ticket issues this test does following:
1. Change on test database FW to OFF - this will increase DML performance.
2. Create table with indexed field of length = maximum that is allowed by
current FB implementation (page_size / 4 - 9 bytes).
3. Try to insert enough number of records in this table - this should cause
runtime exception SQLSTATE = 54000, "Maximum index level reached"
4. Start validation of database: index should NOT be corrupted in its report.
Checked on WI-V3.0.0.32140 (CS, SC); WI-V3.0.0.32157 - official RC1 (SS)
The text was updated successfully, but these errors were encountered: