I think I’m getting closer to the problem. It seems that even though the root object exists, it can’t be found. The error message displayed when trying to delete this project can be found in sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java
(tag 7.9.2). Unfortunately I’m not familiar with Java, so I’ve chosen to put the web component in TRACE mode and luckily I found a hint.
When trying to delete a project through the API, these queries are executed (seen in web.log):
sql=select pb.uuid as uuid, pb.project_uuid as projectUuid, pb.kee as kee, pb.key_type as keyType, pb.branch_type as branchType, pb.merge_branch_uuid as mergeBranchUuid, pb.pull_request_binary as pullRequestBinary, pb.manual_baseline_analysis_uuid as manualBaseline from project_branches pb where pb.project_uuid = ? | params=<id_mentioned_in_error_message>
sql=select p.id, p.uuid from projects p where ( p.project_uuid=? and p.scope = 'PRJ' and p.qualifier in ('SVW','BRC') ) or ( uuid=? and p.scope = 'PRJ' and p.qualifier in ('APP', 'VW','TRK') ) | params=<id_mentioned_in_error_message>, <id_mentioned_in_error_message>
More interesting seems to be query #2 and there the second part after or
. I tried it directly with a database client with two different project_uuids and - surprisingly or not - I got different results. While a current existing project prints out the information as desired, the problematic ID shows nothing. Example:
Query attempt 1:
select
p.id,
p.uuid,
p.root_uuid,
p.project_uuid
from
projects p
where
( project_uuid = 'AV2DeHkG5_gkRVehjwZ-'
and p.scope = 'PRJ'
and p.qualifier in ('APP', 'VW', 'TRK') )
Output:
id |uuid |root_uuid |project_uuid |
-----|--------------------|--------------------|--------------------|
43616|AV2DeHkG5_gkRVehjwZ-|AV2DeHkG5_gkRVehjwZ-|AV2DeHkG5_gkRVehjwZ-|
Query attempt #2:
select
p.id,
p.uuid,
p.root_uuid,
p.project_uuid
from
projects p
where
( uuid = 'AV2DeHkG5_gkRVehjwZ-'
and p.scope = 'PRJ'
and p.qualifier in ('APP', 'VW', 'TRK') )
Output:
id|uuid|root_uuid|project_uuid|
--|----|---------|------------|
The only thing between those two statements is that in the second attempt I just deleted project_
and left uuid
over. The string I search for is untouched.
The same here for a valid project with a different ID:
select
p.id,
p.uuid,
p.root_uuid,
p.project_uuid
from
projects p
where
( project_uuid = 'AV2DeLbF5_gkRVehkCsj'
and p.scope = 'PRJ'
and p.qualifier in ('APP', 'VW', 'TRK') )
id |uuid |root_uuid |project_uuid |
------|--------------------|--------------------|--------------------|
324028|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|
select
p.id,
p.uuid,
p.root_uuid,
p.project_uuid
from
projects p
where
( uuid = 'AV2DeLbF5_gkRVehkCsj'
and p.scope = 'PRJ'
and p.qualifier in ('APP', 'VW', 'TRK') )
id |uuid |root_uuid |project_uuid |
------|--------------------|--------------------|--------------------|
324028|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|AV2DeLbF5_gkRVehkCsj|
Conclusion is that the deletion process can’t find the desired root object even though it’s in the database. The problematic ID can be found with the project_uuid
, but not with the uuid
, even though both strings are the same.
Next step is to find out what’s going on with the column. Maybe it’s an issue with character encoding or problems with characters like hyphen.
Regards, Thomas