Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Started to get an error from OpenId TokenCleanupBackgroundWorker #21024

Closed
1 task done
espindl opened this issue Oct 9, 2024 · 8 comments
Closed
1 task done

Started to get an error from OpenId TokenCleanupBackgroundWorker #21024

espindl opened this issue Oct 9, 2024 · 8 comments
Assignees

Comments

@espindl
Copy link

espindl commented Oct 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

I know this is not directly a bug but it may be directing us to an issue.

I am using Volo.Abp.Account.Web.OpenIddict and Volo.Abp.Identity.Web both Version="8.1.3"

Somehow I started to get a deletion error like this. And it is periodically throwing this.

Why did something like this may happen?
And
How to solve this issue?

Failed executing DbCommand ("5"ms) [Parameters=["@__ef_filter__p_0='?' (DbType = Boolean), @__authorizations_0='?' (DbType = Object)"], CommandType='Text', CommandTimeout='300']"
""DELETE FROM "OpenIddictAuthorizations" AS o
WHERE (@__ef_filter__p_0 OR NOT (o."IsDeleted")) AND o."Id" = ANY (@__authorizations_0)"

23503: update or delete on table "OpenIddictAuthorizations" violates foreign key constraint "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId" on table "OpenIddictTokens"

Reproduction Steps

I do not know, because it started to happen without any intervention.

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

8.1.3

User Interface

Angular

Database Provider

EF Core (Default)

Tiered or separate authentication server

Tiered

Operation System

Linux

Other information

No response

@espindl espindl added the bug label Oct 9, 2024
@maliming maliming self-assigned this Oct 10, 2024
@maliming
Copy link
Member

maliming commented Oct 10, 2024

hi @espindl

You can try to configure the OpenIddict entities to enable the DeleteBehavior.Cascade and update migrations.

image

@maliming
Copy link
Member

hi @espindl

Have you tried that?

@espindl
Copy link
Author

espindl commented Oct 14, 2024

Unfortunately not yet. But I will try it today and inform here.... Thank you...

@espindl
Copy link
Author

espindl commented Oct 14, 2024

You can try to configure the OpenIddict entities to enable the DeleteBehavior.Cascade and update migrations.

That worked... Thank you @maliming

I modified like these:
delete cascade

  • OpenIddictApplication foreign key for OpenIddictAuthorization
  • OpenIddictApplication and OpenIddictAuthorization foreign keys for OpenIddictToken

@maliming
Copy link
Member

maliming commented Oct 16, 2024

hi @espindl

This has nothing to do with cascade deletion. I think there is a problem with your data. If you can share the detailed Debug log, I can check it again.

public class Program
{
    public async static Task<int> Main(string[] args)
    {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Debug()
            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
            .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Debug)

@maliming maliming removed the bug label Oct 16, 2024
@maliming maliming removed this from the 9.0-final milestone Oct 16, 2024
@espindl
Copy link
Author

espindl commented Oct 16, 2024

It was happening on prod, and after the DB changes it was resolved, so I do not have any logs now.

My understanding about the issue is:
After or during a framework update deployment, something wrong happened with the data (one of the updates which has some changes on OpenId system in Abp). And because these cascades were not there, we were getting that error every hour or so (I guess a job is working every hour to clean the OpenID system). But I do not know how this inconsistency happened in the first place.

Do you think I should revert the changes? @maliming

@maliming
Copy link
Member

Do you think I should revert the changes? @maliming

Yes. You can try that. You can share the logs and data in your Database if you get new errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants