Error during Sonar runner execution, expected one element but was...

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Error during Sonar runner execution, expected one element but was...

johan esbjorner

Hi, we have started to get the following error for a couple of our Sonar jobs.

 

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  INFO: EXECUTION FAILURE

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  Total time: 1:08.815s

08:05:49  Final Memory: 13M/247M

08:05:49  INFO: ------------------------------------------------------------------------

08:05:49  ERROR: Error during Sonar runner execution

08:05:49  ERROR: Unable to execute Sonar

08:05:49  ERROR: Caused by: expected one element but was: <org.sonar.api.measures.Measure@622a7bab[id=76874560,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL], org.sonar.api.measures.Measure@12837200[id=76874562,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL]>

08:05:49  ERROR: 
08:05:49  ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.
08:05:49  ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.
08:05:49  Build step 'Invoke Standalone Sonar Analysis' marked build as failure
08:05:49  Finished: FAILURE

 

I have tried to removed duplicated snapshots from the Db as I found in another mail thread without any luck

update snapshots

set snapshots.islast =

where snapshots.islast = 1

and exists(select * from snapshots new_snap

            where new_snap.created_at > snapshots.created_at

            and new_snap.project_id = snapshots.project_id

            and new_snap.islast = 1)

 

 

Versions used:

SonarQube: 3.7.1

DB: SQL server

Sonar runner: 2.2.2

 

Any idea what might have caused this and how to fix it?

 

Best regards

Johan Esbjörner

 




The information contained in this e-mail message is privileged and confidential and is for the exclusive use of the addressee. The person who receives this message and who is not the addressee, one of his employees or an agent entitled to hand it over to the addressee, is informed that he may not use, disclose or reproduce the contents thereof, and is kindly asked to notify the sender and delete the e-mail immediately.

Reply | Threaded
Open this post in threaded view
|

Re: Error during Sonar runner execution, expected one element but was...

Freddy Mallet
Which version of the SCM Activity plugin are you using Johan ?

Thanks

-----
SonarQube for Continuous Inspection


On Mon, Nov 4, 2013 at 11:11 AM, Esbjörner Johan <[hidden email]> wrote:

Hi, we have started to get the following error for a couple of our Sonar jobs.

 

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  INFO: EXECUTION FAILURE

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  Total time: 1:08.815s

08:05:49  Final Memory: 13M/247M

08:05:49  INFO: ------------------------------------------------------------------------

08:05:49  ERROR: Error during Sonar runner execution

08:05:49  ERROR: Unable to execute Sonar

08:05:49  ERROR: Caused by: expected one element but was: <org.sonar.api.measures.Measure@622a7bab[id=76874560,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL], org.sonar.api.measures.Measure@12837200[id=76874562,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL]>

08:05:49  ERROR: 
08:05:49  ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.
08:05:49  ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.
08:05:49  Build step 'Invoke Standalone Sonar Analysis' marked build as failure
08:05:49  Finished: FAILURE

 

I have tried to removed duplicated snapshots from the Db as I found in another mail thread without any luck

update snapshots

set snapshots.islast =

where snapshots.islast = 1

and exists(select * from snapshots new_snap

            where new_snap.created_at > snapshots.created_at

            and new_snap.project_id = snapshots.project_id

            and new_snap.islast = 1)

 

 

Versions used:

SonarQube: 3.7.1

DB: SQL server

Sonar runner: 2.2.2

 

Any idea what might have caused this and how to fix it?

 

Best regards

Johan Esbjörner

 




The information contained in this e-mail message is privileged and confidential and is for the exclusive use of the addressee. The person who receives this message and who is not the addressee, one of his employees or an agent entitled to hand it over to the addressee, is informed that he may not use, disclose or reproduce the contents thereof, and is kindly asked to notify the sender and delete the e-mail immediately.


Reply | Threaded
Open this post in threaded view
|

RE: Error during Sonar runner execution, expected one element but was...

johan esbjorner

Hi Freddy, I was using SCM activity 1.5.1 but upgraded after your mail to SCM activity 1.6.

 

I still get the same kind of error.

08:21:12  INFO: ------------------------------------------------------------------------

08:21:12  INFO: EXECUTION FAILURE

08:21:12  INFO: ------------------------------------------------------------------------

08:21:12  Total time: 25.772s

08:21:12  Final Memory: 12M/213M

08:21:12  INFO: ------------------------------------------------------------------------

08:21:12  ERROR: Error during Sonar runner execution

08:21:12  ERROR: Unable to execute Sonar

08:21:12  ERROR: Caused by: expected one element but was: <org.sonar.api.measures.Measure@1dbd2346[id=76874560,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL], org.sonar.api.measures.Measure@5688755b[id=76874562,metricKey=scm.hash,metric=Metric[id=143,formula=<null>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL]>

08:21:12  ERROR:

08:21:12  ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.

08:21:12  ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.

08:21:12  Build step 'Invoke Standalone Sonar Analysis' marked build as failure

08:21:12  Finished: FAILURE

http://172.28.16.193:8080/static/ee3fff26/images/spinner.gif

 

I noticed that the team had created two jobs (C# based) for the two different SVN branches without using the sonar.branch nor the sonar.dotnet.key.generation.strategy=safe. I have deleted one of the jobs on sonarQube and re-executed the analysis but still get the same error.

 

Regards

Johan

From: Freddy Mallet [mailto:[hidden email]]
Sent: den 4 november 2013 23:10
To: user
Subject: Re: [sonar-user] Error during Sonar runner execution, expected one element but was...

 

Which version of the SCM Activity plugin are you using Johan ?

 

Thanks


-----

SonarQube for Continuous Inspection

 

On Mon, Nov 4, 2013 at 11:11 AM, Esbjörner Johan <[hidden email]> wrote:

Hi, we have started to get the following error for a couple of our Sonar jobs.

 

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  INFO: EXECUTION FAILURE

08:05:48  INFO: ------------------------------------------------------------------------

08:05:48  Total time: 1:08.815s

08:05:49  Final Memory: 13M/247M

08:05:49  INFO: ------------------------------------------------------------------------

08:05:49  ERROR: Error during Sonar runner execution

08:05:49  ERROR: Unable to execute Sonar

08:05:49  ERROR: Caused by: expected one element but was: <[hidden email]>,key=scm.hash,description=<null>,type=STRING,direction=0,domain=SCM,name=Hash,qualitative=false,userManaged=false,enabled=true,origin=JAV,worstValue=<null>,bestValue=<null>,optimizedBestValue=false,hidden=true,deleteHistoricalData=false],value=<null>,data=31a51a52cc41aa0b0fe932e05eee64f357f62a8e,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,date=2013-10-22 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL], [hidden email] 04:04:32.0,variation1=<null>,variation2=<null>,variation3=<null>,variation4=<null>,variation5=<null>,url=<null>,characteristic=<null>,personId=<null>,persistenceMode=FULL]>

08:05:49  ERROR: 
08:05:49  ERROR: To see the full stack trace of the errors, re-run Sonar Runner with the -e switch.
08:05:49  ERROR: Re-run Sonar Runner using the -X switch to enable full debug logging.
08:05:49  Build step 'Invoke Standalone Sonar Analysis' marked build as failure
08:05:49  Finished: FAILURE

 

I have tried to removed duplicated snapshots from the Db as I found in another mail thread without any luck

update snapshots

set snapshots.islast =

where snapshots.islast = 1

and exists(select * from snapshots new_snap

            where new_snap.created_at > snapshots.created_at

            and new_snap.project_id = snapshots.project_id

            and new_snap.islast = 1)

 

 

Versions used:

SonarQube: 3.7.1

DB: SQL server

Sonar runner: 2.2.2

 

Any idea what might have caused this and how to fix it?

 

Best regards

Johan Esbjörner

 




The information contained in this e-mail message is privileged and confidential and is for the exclusive use of the addressee. The person who receives this message and who is not the addressee, one of his employees or an agent entitled to hand it over to the addressee, is informed that he may not use, disclose or reproduce the contents thereof, and is kindly asked to notify the sender and delete the e-mail immediately.

 




The information contained in this e-mail message is privileged and confidential and is for the exclusive use of the addressee. The person who receives this message and who is not the addressee, one of his employees or an agent entitled to hand it over to the addressee, is informed that he may not use, disclose or reproduce the contents thereof, and is kindly asked to notify the sender and delete the e-mail immediately.

Reply | Threaded
Open this post in threaded view
|

Re: Error during Sonar runner execution, expected one element but was...

topagae
In reply to this post by johan esbjorner
Getting this error as well, how was it resolved?
Reply | Threaded
Open this post in threaded view
|

RE: Error during Sonar runner execution, expected one element but was...

topagae
In reply to this post by johan esbjorner
Still getting this error as well as the one it was linked to in the past, how was it resolved?
Reply | Threaded
Open this post in threaded view
|

RE: Error during Sonar runner execution, expected one element but was...

Jose Sa
I also had this problem which seems to happen when the same sonar project is analysed at the same time due to concurrent builds that may share common components.

The previous sql command only updates the "last snapshot" status but doesn't actually delete the duplicated snapshots.

To check for the duplicated snapshots I've ran the following query
mysql> select id,project_id,created_at,build_date,count(build_date) as dups
    -> from snapshots where islast=1 group by project_id,created_at having count(*)>1;
+---------+------------+---------------------+---------------------+------+
| id      | project_id | created_at          | build_date          | dups |
+---------+------------+---------------------+---------------------+------+
| 1097994 |       4090 | 2013-11-27 00:24:16 | 2013-11-27 00:24:17 |    2 |
| 1098002 |       4092 | 2013-11-27 00:24:16 | 2013-11-27 00:24:17 |    2 |
| 1098005 |       4093 | 2013-11-27 00:24:16 | 2013-11-27 00:24:17 |    2 |
| 1098162 |       4189 | 2013-11-27 00:24:16 | 2013-11-27 00:24:49 |    2 |
| 1098163 |       4190 | 2013-11-27 00:24:16 | 2013-11-27 00:24:49 |    2 |
| 1098164 |       4191 | 2013-11-27 00:24:16 | 2013-11-27 00:24:49 |    2 |
| 1098165 |       4192 | 2013-11-27 00:24:16 | 2013-11-27 00:24:49 |    2 |
| 1098166 |       4193 | 2013-11-27 00:24:16 | 2013-11-27 00:24:49 |    2 |
| 1098138 |       4194 | 2013-11-27 00:24:16 | 2013-11-27 00:24:43 |    2 |
| 1098139 |       4195 | 2013-11-27 00:24:16 | 2013-11-27 00:24:43 |    2 |
| 1098140 |       4196 | 2013-11-27 00:24:16 | 2013-11-27 00:24:43 |    2 |
| 1098141 |       4197 | 2013-11-27 00:24:16 | 2013-11-27 00:24:43 |    2 |
| 1098142 |       4198 | 2013-11-27 00:24:16 | 2013-11-27 00:24:43 |    2 |
+---------+------------+---------------------+---------------------+------+
13 rows in set (0.29 sec)

so all I needed to do is delete the duplicated snapshots with the following query using the previous one as temporary table aliased as "subquery":
delete from snapshots where id in (
    select id from (
        select id from snapshots where islast=1 group by project_id,created_at having count(*)>1
    ) subquery
);

Still this means there is still concurrency issue when creating the snapshots that is causing this problem in Sonar 3.7 (haven't tried more recent one yet).
Reply | Threaded
Open this post in threaded view
|

RE: Error during Sonar runner execution, expected one element but was...

Jose Sa
Re-analysing this a bit further I can see that the problem goes beyond the "last" snapshot and older snapshots may also have duplicates.

The following query shows a simplified view of all projects that have duplicated snapshots in the same timestamp:
select id,project_id,created_at,count(*) as dups from snapshots
group by project_id,created_at having count(*)>1;

+---------+------------+---------------------+------+
| id      | project_id | created_at          | dups |
+---------+------------+---------------------+------+
| 1523946 |        295 | 2013-07-08 18:20:17 |    2 | 
| 1546848 |        295 | 2013-09-04 15:06:21 |    3 | 
| 1617494 |        300 | 2014-01-09 12:11:46 |    2 | 
...
+---------+------------+---------------------+------+
42 rows in set (0.02 sec)

For more detailed list you can use the query:
select id,snaps.project_id,snaps.created_at,build_date,status,islast
from snapshots snaps inner join (
    select project_id,created_at from snapshots 
    group by project_id,created_at having count(*)>1
) dups ON snaps.project_id=dups.project_id and snaps.created_at=dups.created_at;

+---------+------------+---------------------+---------------------+--------+--------+
| id      | project_id | created_at          | build_date          | status | islast |
+---------+------------+---------------------+---------------------+--------+--------+
|  811411 |         41 | 2013-10-08 00:05:30 | 2013-10-08 00:06:45 | P      |      0 |
|  811469 |         41 | 2013-10-08 00:05:30 | 2013-10-08 00:06:47 | P      |      0 |
|  806620 |         79 | 2013-10-07 15:28:32 | 2013-10-07 15:30:21 | P      |      0 |
|  807188 |         79 | 2013-10-07 15:28:32 | 2013-10-07 15:34:44 | P      |      0 |
|  807631 |         79 | 2013-10-07 15:28:32 | 2013-10-07 15:37:00 | P      |      0 |
...
+---------+------------+---------------------+---------------------+--------+--------+
165 rows in set (0.13 sec)

To delete the older snapshots you can run the following query as many times as needed until no affected rows are shown, or add it to cron for periodic cleanup.
delete from snapshots where id in (
    select id from (
        select id from snapshots group by project_id,created_at having count(*)>1
    ) projs_with_dups
);