Subject Re: Deadlock during index activation
Author hvlad
--- In firebird-support@yahoogroups.com, "Alec L" wrote:
>
> I forgot to mention that we are using Firebird 2.1.2 on Windows XP SP3 in Embedded mode. The statement that activates indexes is executed via the Jaybird JDBC driver 2.1.6.
>
> Does anybody have any thoughts on this?
>
> --- In firebird-support@yahoogroups.com, Alec Swan wrote:
> >
> > Hello,
> >
> > Could anybody explain what could cause a deadlock during index
> > activation on the entire database?
> >
> > EXECUTE BLOCK AS DECLARE VARIABLE stmt VARCHAR(1000); BEGIN for select
> > 'ALTER INDEX "'||rdb$index_name ||'" ACTIVE;'
> > from rdb$indices
> > where rdb$system_flag is not null and rdb$system_flag = 0 into :stmt
> > do EXECUTE STATEMENT :stmt; END;
> >
> > GDS Exception. 335544336. deadlock
> > Reason: deadlock

When Firebird creates index it takes PR (protected read) lock on table's metadata to prevent concurrent modifications of data (else index will be not consistent). If index is related to FK constraint then locks for both tables should be taken.
If engine can't take lock it will return appropriate error.
It seems you have not full error message but only primary error code.

Regards,
Vlad