Sonarqube Background Analysis is Failing Randomly With PLSQL Error

I have been trying to integrate Sonarqube Analysis with Quality gate for one of my java project in Jenkins. The build tool we are using is Gradle. The analysis shows passed in the Jenkins , but when checked in Sonarqube it shows "Background Analysis is failed " . This error makes the quality gate also to fail .
Error :

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.postgresql.util.PSQLException: ERROR: column m.user_managed does not exist
  Position: 178
### The error may exist in org.sonar.db.metric.MetricMapper
### The error may involve org.sonar.db.metric.MetricMapper.selectAllEnabled-Inline
### The error occurred while setting parameters
### SQL: SELECT           m.uuid,     m.name as kee,     m.description,     m.direction,     m.domain,     m.short_name as shortName,     m.qualitative,     m.val_type as valueType,     m.user_managed as userManaged,     m.enabled,     m.worst_value as worstValue,     m.best_value as bestValue,     m.optimized_best_value as optimizedBestValue,     m.hidden,     m.delete_historical_data as deleteHistoricalData,     m.decimal_scale as decimalScale         FROM metrics m      WHERE  m.enabled=true      ORDER BY UPPER(m.short_name), m.short_name
### Cause: org.postgresql.util.PSQLException: ERROR: column m.user_managed does not exist
  Position: 178

Full error log is shared
sonarerror.txt (10.9 KB)

  • SonarVersion : 9.1 developer Version

  • Scanner Plugin Version 2.13.1

  • Build Tool : Gradle

  • CI/CD : Jenkins