Getting 500 response (db error) on applying filter "label=any" on issue list - after updating to 13.0.6

Summary

In when applying filter "label: any" gitlab answers with 500. I rececntly updated our selfhosted instance from 12.7.5 to 13.0.6 (12.7.5->12.7.9->12.8.10->12.9.10->12.10.11->13.0.6) and since then the error occurs.
In the gitlab production logs it tells me something about PG::InvalidColumnReference.
Since the error starts to occur after updating i guess its some kind of db migration problem.

Steps to reproduce

See summary

Example Project

I wasnt able to reproduce this on gitlab.com

What is the current bug behavior?

Gitlab answers with 500 on requesting issues with filter "label=any".

What is the expected correct behavior?

list every issue which has a label

Relevant logs and/or screenshots

{
   "method":"GET",
   "path":"/[filtered]/-/issues",
   "format":"html",
   "controller":"Projects::IssuesController",
   "action":"index",
   "status":500,
   "time":"2020-06-23T10:30:57.491Z",
   "params":[
      {
         "key":"scope",
         "value":"all"
      },
      {
         "key":"utf8",
         "value":"✓"
      },
      {
         "key":"state",
         "value":"opened"
      },
      {
         "key":"label_name",
         "value":[
            "Any"
         ]
      },
      {
         "key":"namespace_id",
         "value":"[filtered]"
      },
      {
         "key":"project_id",
         "value":"api-server"
      }
   ],
   "remote_ip":"[filtered]",
   "user_id":2,
   "username":"[filtered]",
   "ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36",
   "queue_duration_s":0.011961,
   "correlation_id":"[filtered]",
   "meta.user":"[filtered]",
   "meta.project":"[filtered]",
   "meta.root_namespace":"[filtered]",
   "meta.caller_id":"Projects::IssuesController#index",
   "redis_calls":6,
   "redis_duration_s":0.001284,
   "cpu_s":0.08,
   "exception.class":"ActiveRecord::StatementInvalid",
   "exception.message":"PG::InvalidColumnReference: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...state_id\" IN (1)) GROUP BY \"issues\".\"id\" ORDER BY COUNT(awar...\n                                                             ^\n",
   "exception.backtrace":[
      "lib/gitlab/issuable_metadata.rb:18:in `map'",
      "lib/gitlab/issuable_metadata.rb:18:in `issuable_meta_data'",
      "app/controllers/concerns/issuable_collections.rb:47:in `set_pagination'",
      "app/controllers/concerns/issuable_collections.rb:22:in `set_issuables_index'",
      "ee/lib/gitlab/ip_address_state.rb:10:in `with'",
      "ee/app/controllers/ee/application_controller.rb:44:in `set_current_ip_address'",
      "app/controllers/application_controller.rb:496:in `set_current_admin'",
      "lib/gitlab/session.rb:11:in `with_session'",
      "app/controllers/application_controller.rb:487:in `set_session_storage'",
      "app/controllers/application_controller.rb:481:in `set_locale'",
      "lib/gitlab/error_tracking.rb:48:in `with_context'",
      "app/controllers/application_controller.rb:546:in `sentry_context'",
      "app/controllers/application_controller.rb:474:in `block in set_current_context'",
      "lib/gitlab/application_context.rb:52:in `block in use'",
      "lib/gitlab/application_context.rb:52:in `use'",
      "lib/gitlab/application_context.rb:20:in `with_context'",
      "app/controllers/application_controller.rb:467:in `set_current_context'",
      "ee/lib/gitlab/jira/middleware.rb:19:in `call'"
   ],
   "db_duration_s":0.01211,
   "view_duration_s":0.0,
   "duration_s":0.06241
}

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.6.6p146
Gem Version:    2.7.10
Bundler Version:1.17.3
Rake Version:   12.3.3
Redis Version:  5.0.9
Git Version:    2.26.2
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information
Version:        13.0.6-ee
Revision:       4c8f8b0d9ee
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     11.7
URL:            https://gitlab
HTTP Clone URL: https://gitlab/some-group/some-project.git
SSH Clone URL:  git@gitlab:some-group/some-project.git
Elasticsearch:  no
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        13.2.0
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 13.2.0 ? ... OK (13.2.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Checking Reply by email ...

IMAP server credentials are correct? ... no Try fixing it: An error occurred: Net::IMAP::NoResponseError: authentication failed Check that the information in config/gitlab.yml is correct For more information see: doc/administration/reply_by_email.md Please fix the error above and rerun the checks. Init.d configured correctly? ... skipped MailRoom running? ... skipped

Checking Reply by email ... Finished

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 5/1 ... yes 6/4 ... yes 7/5 ... yes 6/6 ... yes 7/7 ... yes 8/8 ... yes 5/9 ... yes 5/10 ... yes 16/12 ... yes 7/13 ... yes 7/15 ... yes 6/19 ... yes 5/21 ... yes 2/24 ... yes 5/26 ... yes 2/29 ... yes 7/35 ... yes 6/36 ... yes 6/40 ... yes 4/42 ... yes 2/44 ... yes 5/45 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.6) Git version >= 2.22.0 ? ... yes (2.26.2) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1592909911 sudo mv /var/opt/gitlab/.ssh/id_rsa.pub ~/gitlab-check-backup-1592909911 sudo mv /var/opt/gitlab/.ssh/id_rsa ~/gitlab-check-backup-1592909911 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 7 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... no Try fixing it: Please migrate all projects to hashed storage as legacy storage is deprecated in 13.0 and support will be removed in 14.0. For more information see: doc/administration/repository_storage_types.md Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)