# SSO login and Jobs::EnsureDbConsistency both fail

**URL:** <https://meta.discourse.org/t/sso-login-and-jobs-ensuredbconsistency-both-fail/55515>\
**Category:** Bug\
**Created:** [January 10, 2017, 7:15pm UTC](https://meta.discourse.org/t/sso-login-and-jobs-ensuredbconsistency-both-fail/55515 "2017-01-10T19:15:34Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)\
**Post date:** [January 10, 2017, 7:15pm UTC](https://meta.discourse.org/t/sso-login-and-jobs-ensuredbconsistency-both-fail/55515/1 "2017-01-10T19:15:34Z")

</div>

I have two sites having SSO enabled. After the latest update, both of them started failing SSO logons for moderators and admins (but not for normal users), with a localized error message that is similar to “name is already being used”:

```plaintext
          Verbose SSO log: Record was invalid: Group 3

          {:name=>"wird bereits verwendet"}

          

          nonce: ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
name: Felix Freiberger
username: felix.freiberger
email: ■■■■■■■■■■■■■■■■■■■■■■■■
avatar_url: 
avatar_force_update: 
require_activation: true
bio: 
external_id: 14
return_sso_url: 
admin: true
moderator: true
suppress_welcome_message: 
add_groups: 
remove_groups: 

```

More intriguingly, the logs also contain failures for `Jobs::EnsureDbConsistency`. They look like this:

```plaintext
Job exception: Validierung gescheitert: Name wird bereits verwendet

```

```plaintext
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/validations.rb:79:in `raise_record_invalid'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/validations.rb:43:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:291:in `block in save!'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:351:in `block in with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:220:in `transaction'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/transactions.rb:291:in `save!'
/var/www/discourse/app/models/group.rb:224:in `refresh_automatic_group!'
/var/www/discourse/app/models/group.rb:248:in `block in refresh_automatic_groups!'
/var/www/discourse/app/models/group.rb:247:in `each'
/var/www/discourse/app/models/group.rb:247:in `refresh_automatic_groups!'
/var/www/discourse/app/models/group.rb:234:in `ensure_consistency!'
/var/www/discourse/app/jobs/scheduled/ensure_db_consistency.rb:8:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'

```

Since my SSO source hasn’t been updated and the internal check job fails, too, I think this is a Discourse bug.

* * *

Group 3 is the “staff” group (which is called “mitarbeiter” in German).

---

_[View the full topic](https://meta.discourse.org/t/sso-login-and-jobs-ensuredbconsistency-both-fail/55515)._
