Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Refreshing tokens leads into a "duplicate key value violates" on postgres

See original GitHub issue

What version of UAA are you running?


What output do you see from curl <YOUR_UAA>/info -H'Accept: application/json' {"app":{"version":"4.8.0"},"links":{"uaa":"http://localhost:8080/uaa","passwd":"/forgot_password","login":"http://localhost:8080/uaa","register":"/create_account"},"zone_name":"uaa","entityID":"cloudfoundry-saml-login","commit_id":"391163e","idpDefinitions":{},"prompts":{"username":["text","Email"],"password":["password","Password"]},"timestamp":"2017-12-04T18:33:28+0000"}

How are you deploying the UAA?

Docker container containing the official JAR from Maven

What did you do?

Refreshing a token

What did you expect to see? What goal are you trying to achieve with the UAA?

I expect to not get any errors in the postgres log.

What did you see instead?

The requests work fine, but I’m getting the following error in the postgres logs:

2017-12-07 15:58:34 UTC:[29756]:ERROR: duplicate key value violates unique constraint "revocable_tokens_pkey"
2017-12-07 15:58:34 UTC:[29756]:DETAIL: Key (token_id)=(1111111111111111111111111111111-r) already exists.
2017-12-07 15:58:34 UTC:[29756]:STATEMENT: INSERT INTO revocable_tokens (token_id,client_id,user_id,format,response_type,issued_at,expires_at,scope,data,identity_zone_id) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)

We traced this down to UaaTokenServices.persistRevocableToken which already contains a comment that this is a known bug. The code basically tries to insert the refresh token again into the database despite it being already there leading into the error above. Would it be possible to fix this error? I suggest that we pass into the persistRevocableToken whether is chould create or update to avoid the error. It is well known if the token should be already in the database or not.

Am I overlooking something?

The whole thing is quite a show-stopper for us because we are getting ERRORs in postgres which appear on our alerting. We could try to ignore them but I would rather try to fix the bug.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

sreetummidicommented, Jan 30, 2018

@jhamon or @fhanik can you comment on this

theomegacommented, Dec 21, 2017

Any idea on this? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hidden dangers of duplicate key violations in PostgreSQL and ...
The “duplicate key violates unique constraint” error notifies the caller that a retry is needed. This seems like an intuitive approach, but ...
Read more >
postgresql duplicate key violates unique constraint
If you get this message when trying to insert data into a PostgreSQL database: ERROR: duplicate key violates unique constraint.
Read more >
PGS-220000 PostgreSQL error: ERROR: duplicate key value ...
PGS-220000 PostgreSQL error: ERROR: duplicate key value violates unique constraint “nmstrackingurl_tagid” DETAIL: Key (stagid) = (1c7bdec2) already exists.
Read more >
Postgres Release Notes - All Versions - Bucardo
Fix handling of DEFAULT tokens that appear in a multi-row VALUES clause of an INSERT on an updatable view (Tom Lane). This oversight...
Read more >
Database Engine events and errors - SQL Server
The number of values in the VALUES clause must match the number of ... Yes, A duplicate key insert was hit when updating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found