Rules not registered and index correctly after upgrade to 10.7

Must-share information (formatted with Markdown):

  • Sonar version: 10.7.0.96327
  • Deployment: Docker with external PostgreSQL DB

When the container is started, the rules should be correctly (re-)indexed even if the old ES index was deleted.

What I observe instead is:

  1. The rules index is empty
  2. There are hundreds of warnings: “Could not retrieve rule with uuid %s referenced by a deprecated rule key…”

TL;DR: The “dbRules” is either an empty list if no plugins have changed or all rules. If no plugins changes, no reindexing happens.

The warning comes from this line:

I debugged the instance on startup, and seems the “dbRules” that is passed here is an empty list (but the DB table for rules has over 11,000 of them, so that’s not the problem).

It seems that this change in 10.7 added a condition on which rules should be processed:

Which is:

I don’t know when the rule.getPluginKey() == null part is supposed to be true, as all rules (even built-in) have a pluginKey set (so it’s always true). Thus the filtering result depends solely on !onlyBuiltIn being true. But onlyBuiltIn == !anyPluginChanged in RulesRegistrant class. So the list becomes empty if no plugins have changed OR its a list of all 11k plugins if any plugin has changed.

3 Likes

PS. The log line is misformatted also, so it shows up as:

2024.10.14 12:08:50 WARN web[][o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule

with the %s marker not replaced by UUID of the rule.

Hi,

Welcome to the community!

Are you using any 3rd-party plugins? And if so, which ones?

And I suppose you’ve tried forcing an ElasticSearch reindex?

 
Ann

I am also experiencing this issue. I see no rules shown in the Rules tab, though rules are applied during scanning.

I noticed the log message “WARN web[o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule”, which is what brought me here.

SonarQube v10.7 (96327) running in docker with postgres in another container.

I have tried forcing a reindex, and also completely reconstructed the container from scratch - no fix.

1 Like

I am only using my custom plugin which doesn’t do anything related to rules. The Docker container runs with non-persistent volumes (only Postgres is persistent), so “forcing ES reindex” happens with every restart.

Hi,

Can you try this without your custom plugin?

 
Thx,
Ann

Same exact issue here after upgrading to 10.7 developer edition. I’m running on an ec2 instance without docker, rds postgres 16.3, no plugins installed. I tried wiping the data/es8 directory and triggering a reindex but see tons of lines:

2024.10.16 17:34:17 WARN  web[][o.s.s.r.r.RulesRegistrationContext] Could not retrieve rule with uuid %s referenced by a deprecated rule key. The following deprecated rule keys seem to be referencing a non-existing rule

Hi @eric_kertz1,

Welcome to the community and thanks for confirming that this is reproducible without plugins!

I’m going to flag this for the team.

 
Ann

4 Likes

No plugins here. Clean install, same problem.

2 Likes

Same problem here, no plugins. Are there any temporary work-arounds available?

Just checking in if there are any updates on this. I also noticed that since the rules are broken sonarlint in connected mode is also not showing any issues.

1 Like

Thanks for the report. I can reproduce the issue and have started investigating. I’m working on a patch, but if I can find a workaround to unblock you, I will let you know.

You can follow [SONAR-23466] - Jira

6 Likes

Thanks, hope we get a resolution soon. I tried the workaround mentioned in that story, didn’t work for me.

Hum, that’s bad news. Would you mind sharing the server startup logs after clearing the ES data and the plugin hash in the DB? I’d like to check if there are no other problems.

Apologies, I tried again and it worked this time - not sure what I did the first time! Thanks.

1 Like

Thank you, the work-around worked for us as well!

1 Like

Hmm… the work-around did work, and we could see the Rules again. But then we rebooted the pod, effectively clearing the es8 directory, and afterwards the Rules were gone again :frowning:

Hi @flute,

Until 10.8 is out, maybe you want to enable persistency for your indices.

 
HTH,
Ann

1 Like

@Chromobotia @flute @eric_kertz1 @lukrek_syncron
Did you face the problem right away after the upgrade, or did you restart the server?

@ ganncamp - thanks, we might do that

@ Lena - we run in k8s without persistence, so every restart is a wipe of the data folder. First start after the upgrade, we still saw all Rules. But a colleague of mine noticed that his rule customizations had been lost (different bug, User "system" automatically reactivates rule upon restart - #6 by ganncamp ). We then restarted the pod to see if that would help, but that second reboot made the Rules “invisible”.

Likewise, after I did the workaround, we had our Rules back. But after restarting the pod, they were lost again.

1 Like