Skip to content

Crash when creating index on table that uses UDR and ParallelWorkers > 1 #8386

@hvlad

Description

@hvlad

Original issue was reported by user privately.

The crash happens on SuperServer only, table should be big enough to have more than one pointers page.
Also table must depend on some UDR, for example, use UDR in computed field.

Steps to reproduce

-- create test database
create database 'test_udr.fdb';

-- make sure ParallelWorkers > 1 in firebird.conf
select rdb$config_value from rdb$config
 where rdb$config_name = 'ParallelWorkers';

-- create UDR
create function sum_args (
 n1 integer,
 n2 integer,
 n3 integer
) returns integer
 external name 'udrcpp_example!sum_args'
 engine udr;

-- make sure it works
select sum_args(1, 2, 3) from rdb$database;

SUM_ARGS
========
   6

commit;

-- create table with dependency on UDR
create table t (
  f1 int,
  f2 int,
  f3 int,
  f_sum computed by (sum_args(f1, f2, f3))
);

-- fill it with some data
insert into t values (1, 1, 1);
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
insert into t select f1, f2, f3 from t;
commit;

-- make sure there are at least 2 pointer pages
select count(*) from rdb$pages p join rdb$relations r on p.rdb$relation_id = r.rdb$relation_id
 where r.rdb$relation_name = 'T' 
   and p.rdb$page_type = 4;

		COUNT
=================
			2

-- create index 
create index t_idx_f1 on t(f1);

Release build crashed silently.

Thread stack in release build

fbclient.dll!Why::YAttachment::YAttachment(Firebird::IProvider * aProvider=0x0000000000000000, Firebird::IAttachment * aNext=0x000000000430e418, const Firebird::StringBase<Firebird::PathNameComparator> & aDbPath) Line 5542
	at src\yvalve\why.cpp(5542)
fbclient.dll!Why::MasterImplementation::registerAttachment(Firebird::IProvider * provider=0x0000000000000000, Firebird::IAttachment * attachment=0x000000000430e418) Line 3945
	at src\yvalve\why.cpp(3945)
fbclient.dll!Firebird::IMasterBaseImpl<Why::MasterImplementation,Firebird::CheckStatusWrapper,Firebird::IVersionedImpl<Why::MasterImplementation,Firebird::CheckStatusWrapper,Firebird::Inherit<Firebird::IMaster>>>::cloopregisterAttachmentDispatcher(Firebird::IMaster * self=0x0000000000465bb8, Firebird::IProvider * provider=0x00007ff973c5100c, Firebird::IAttachment * attachment=0x0000000000000004) Line 7666
	at src\include\firebird\IdlFbInterfaces.h(7666)
[Inline Frame] engine13.dll!Firebird::IMaster::registerAttachment(Firebird::IProvider *) Line 393
	at src\include\firebird\IdlFbInterfaces.h(393)
engine13.dll!Jrd::ExtEngineManager::ExternalContextImpl::ExternalContextImpl(Jrd::thread_db * tdbb=0x00000000063bdbd8, Firebird::IExternalEngine * aEngine) Line 636
	at src\jrd\ExtEngineManager.cpp(636)
engine13.dll!Jrd::ExtEngineManager::getEngineAttachment(Jrd::thread_db * tdbb=0x00000000063bdbd8, Firebird::IExternalEngine * engine=0x0000000006210798, bool closing=false) Line 1801
	at src\jrd\ExtEngineManager.cpp(1801)
[Inline Frame] engine13.dll!Jrd::ExtEngineManager::getEngineAttachment(Jrd::thread_db *) Line 1780
	at src\jrd\ExtEngineManager.cpp(1780)
engine13.dll!Jrd::ExtEngineManager::makeFunction(Jrd::thread_db * tdbb=0x00000000063bdbd8, Jrd::CompilerScratch * csb=0x000000000640cec0, Jrd::Function * udf=0x0000000006521060, const Jrd::MetaName & engine={...}, const Firebird::StringBase<Firebird::StringComparator> & entryPoint={...}, const Firebird::StringBase<Firebird::StringComparator> & body={...}) Line 1334
	at src\jrd\ExtEngineManager.cpp(1334)
engine13.dll!Jrd::Function::loadMetadata(Jrd::thread_db * tdbb=0x00000000063bdbd8, unsigned short id=22784, bool noscan=216, unsigned short flags=52624) Line 1172
	at gen\jrd\Function.cpp(1172)
engine13.dll!Jrd::Function::lookup(Jrd::thread_db * tdbb=0x00000000063bdbd8, const Jrd::QualifiedName & name={...}, bool noscan) Line 667
	at gen\jrd\Function.cpp(667)
engine13.dll!Jrd::UdfCallNode::parse(Jrd::thread_db * tdbb=0x00000000063bdbd8, Firebird::MemoryPool & pool={...}, Jrd::CompilerScratch * csb=0x0000000006404c40, const unsigned char blrOp) Line 12894
	at src\dsql\ExprNodes.cpp(12894)
engine13.dll!PAR_parse_node(Jrd::thread_db * tdbb=0x00000000063bdbd8, Jrd::CompilerScratch * csb=0x0000000006404c40) Line 1651
	at src\jrd\par.cpp(1651)
engine13.dll!PAR_blr(Jrd::thread_db * tdbb=0x00000000063bdbd8, Jrd::jrd_rel * relation, const unsigned char * blr=0x00000000063bd1b9, unsigned long blr_length=28, Jrd::CompilerScratch * view_csb=0x0000000000000000, Jrd::CompilerScratch * * csb_ptr=0x0000000000000000, Jrd::Statement * * statementPtr=0x0000000000000000, const bool trigger=false, unsigned short flags=1024) Line 187
	at src\jrd\par.cpp(187)
engine13.dll!MET_scan_relation(Jrd::thread_db * tdbb=0x00000000063bdbd8, Jrd::jrd_rel * relation=0x00000000064029c0) Line 9615
	at gen\jrd\met.cpp(9615)
engine13.dll!Jrd::IndexCreateTask::handler(Firebird::Task::WorkItem & _item={...}) Line 483
	at src\jrd\idx.cpp(483)
[Inline Frame] engine13.dll!Firebird::Worker::work(Firebird::WorkerThread *) Line 149
	at src\common\Task.cpp(149)
engine13.dll!Firebird::WorkerThread::threadRoutine() Line 63
	at src\common\Task.cpp(63)
[Inline Frame] engine13.dll!`anonymous-namespace'::ThreadArgs::run() Line 78
	at src\common\ThreadStart.cpp(78)
engine13.dll!threadStart(void * arg=0x000000000430d790) Line 97
	at src\common\ThreadStart.cpp(97)
[External Code]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions