SQL command to do the Jira Integrity Checking

Hi,

I am using the Integrity Checking to run the workflow checking. But the checking taken too long time, and got the timeout error.

Did anyone try any sql command instead GUL for the checking, "Check workflow entry states are correct" ?

Please do advise, thanks

Hooi Peng

2 answers

This widget could not be displayed.

Some tips

-- worklog entries
select * from worklog where issueid is null;
select * from worklog where timeworked is null;
select * from worklog where not exists (select * from jiraissue where id=issueid);


-- issues without project 
select * from jiraissue where project is null;


-- no issues for version
select id from projectversion where not exists (
select * from  NODEASSOCIATION where sink_node_id =id and Sink_node_entity='Version' 
and source_node_entity='Issue');

-- no project for version
select id from projectversion v where not exists (
select * from  project where id=v.project);
 

-- no issue  for  version-issue record
select vname, p.pkey, sink_node_id issueid from projectversion v, project p, NODEASSOCIATION 
where v.id=sink_node_id 
and  sink_node_entity='Version' 
and source_node_entity='Issue'
and p.id=v.project
and not exists (select * from jiraissue where  id=source_node_id);

-- no version for  version-issue record 
select p.pkey,issuenum, sink_node_id versionid from jiraissue i, project p, NODEASSOCIATION where p.id=i.project and 
i.id = source_node_id and Sink_node_entity='Version' 
and source_node_entity='Issue'
and not exists (select * from projectversion where  id=sink_node_id);

-- subtasks without parents
select p.pkey, i.issuenum,t.pname from issuetype t ,jiraissue i, project p  
where i.issuetype=t.id and p.id=i.project and t.pstyle='jira_subtask'
and not exists (select * from issuelink where linktype=10100  and destination=i.id);


-- issues with null issuenum


select p.pkey, issuenum, i.id from jiraissue i left join  project p on ( p.id=i.project) where issuenum is null;


-- subtasks from another project


 select sp.pkey, si.issuenum, si.id, dp.pkey, di.issuenum, di.id     
  from issuelink l, jiraissue di, jiraissue si, project sp, project dp
  where linktype=10100
  and si.id=source and di.id=destination and si.project=sp.id and di.project=dp.id
  and dp.pkey!=sp.pkey;


-- classic-board versions that do not exists in projectversion (Oracle)

select * from     
(select  distinct extractvalue(value(t),'/long') id from TABLE(XMLSEQUENCE(
(select  
XMLAGG(extract(XMLTYPE(propertyvalue),'/map/entry[string="VERSION_MATCHUP"]//long')) 
from propertytext where  propertyvalue  like '%VERSION_MATCHUP%'))
) t) gh where not exists (select * from projectversion where id=gh.id);


 
-- orphan issuelinks
select * from issuelink   where not exists (select * from jiraissue where id=source)
or not exists (select * from jiraissue where id=destination) ;


-- versions with wrong projects  
select  p.pkey, i.issuenum,  v.vname, p.id project_project, 
(select pkey from project where id=v.project) version_project from jiraissue i, NODEASSOCIATION, project p, projectversion v 
where i.id =source_node_id
and sink_node_entity='Version' 
and source_node_entity='Issue'
and sink_node_id=v.id
and p.id=i.project
and v.project!=i.project
-- changegroup without issue id
select * from changeitem where groupid in (
select id from changegroup
where not exists (select * from jiraissue where id=issueid)
);
This widget could not be displayed.

Look the the following classes source code and try to construct the query(ies):

com.atlassian.jira.appconsistency.integrity.check.WorkflowStateCheck

com.atlassian.jira.appconsistency.integrity.check.WorkflowCurrentStepCheck

com.atlassian.jira.appconsistency.integrity.check.WorkflowIssueStatusNull

It will be nice if you post the SQL here if you manage to construct it, so other can re-use it :)

2 of them are here https://confluence.atlassian.com/jirakb/how-to-run-the-workflow-integrity-checks-in-sql-658179102.html

But WorkflowCurrentStepCheck seems to be the most time consuming and the one that usually crashes the standard jira integrity check 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

200 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you