We are using SonarQube 10.1 (build 73491) with a 5mm LOC license and recently migrated from one server to another (we got a new license generated for it). It’s unclear if the issue is related to the migration, but what we are observing right now is that the License Configuration shows that we’ve analyzed 4.9mm+ LOC and, basically, refuses to scan additional projects whereas, in reality, we have not analyzed more than 2.2mm LOC.
We ran the /api/projects/license_usage report and adding up the projects shows 2.21mm LOC and 44% licenseUsagePercentage.
How can we get back the remaining 56% (or 2.8mm LOC) from our license?
I’m not sure how to show you the actual usage but you can see that our projects go down in size very quickly. We’ve actually had to remove some projects just so we can unblock the license from saying we’ve reached our limit (even though we are very far from the limit). I believe we are now below 2mm LOC analyzed but the server is showing 4.75mm LOC
No, deleting projects brought us down from 4.9 to 4.7mm according to the license page but we actually have 2.2mm (2mm after the deletion). So we are still in a situation where we pay for 5mm but we are only getting 2mm LOC.
Hey @nkojuharov, thanks for reporting this. I think you just found a bug.
To confirm, could you please run this SQL query on your database, and tell us if the query returns any rows? I don’t need you to post the result here, I only need to know if the query found any results.
loc_grouped_branches.ncloc as loc,
select pb.project_uuid as projectUuid,
p.name as projectName,
p.kee as projectKey,
pb.kee as branchName,
pb.branch_type as branchType,
lm.value as ncloc,
row_number() over (partition by pb.project_uuid order by lm.value desc, pb.uuid asc) row_number
from live_measures lm
inner join project_branches pb on pb.uuid = lm.component_uuid
inner join projects p on p.uuid = pb.project_uuid
where lm.metric_uuid = (select uuid from metrics m where name = 'ncloc')
and p.qualifier ='TRK'
inner join projects p on p.uuid = loc_grouped_branches.projectUuid
where loc_grouped_branches.row_number = 1
and loc_grouped_branches.ncloc != p.ncloc
order by loc_grouped_branches.ncloc desc
If this returns any result, it means that some branches from your projects were deleted (manually, or through an automatic purge for inactivity), and the “new” LOC score for the project was not correctly updated after the purge. If my assumption is correct, if you compute the sum of diff between the loc and ncloc columns, you will find the same gap you already noticed between SQ UI and api/projects/license_usage.
In this case, as a workaround, you can re-analyze any branches from the projects found in the query: the new analysis will fix the LOC count for the project.