[Bug]: Error logging in - Cannot insert duplicate key row in object 'dbo.UserAuthentication' with unique index 'IX_UserAuthentication' #7313
-
Is there an existing issue for this?
What happened?I am using a module to delegate auth on azure AD (https://github.com/davidjrh/dnn.azureadprovider). I do not see a way of this error happening as it is checked in the previous line: I actualy see in the database table ([UserAuthentication]) the rows with the correct UserIDs and UserNames (tokens) for the users that cannot login. I am focusing on this code as the stack trace points to it. I am looking for any ideas that might help diagnose this strange behaviour. Steps to reproduce?Unable to reproduce localy due to infrastructure complexity Current BehaviorNo response Expected BehaviorNo response Relevant log outputAbsoluteURL:/Default.aspx
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:37166c6b-5a92-4196-8468-c7e52e0ed75f
RawUrl:/login?code=1.AUcAUeKEmhJgH****jB
Referrer:https://login.microsoftonline.com/
Message:Cannot insert duplicate key row in object 'dbo.UserAuthentication' with unique index 'IX_UserAuthentication'. The duplicate key value is (123, Azure). The statement has been terminated.
StackTrace:
InnerMessage:Cannot insert duplicate key row in object 'dbo.UserAuthentication' with unique index 'IX_UserAuthentication'. The duplicate key value is (123, Azure). The statement has been terminated.
InnerStackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteScalar()
at PetaPoco.Database.CommandHelper(IDbCommand cmd, Func`2 executionFunction)
at PetaPoco.Database.ExecuteScalarInternal[T](CommandType commandType, String sql, Object[] args)
at DotNetNuke.Data.PetaPoco.PetaPocoHelper.ExecuteScalar[T](String connectionString, CommandType type, Int32 timeoutSec, String sql, Object[] args)
at DotNetNuke.Data.SqlDataProvider.ExecuteScalar[T](String procedureName, Object[] commandParameters)
at DotNetNuke.Services.Authentication.OAuth.OAuthClientBase.AuthenticateUser(UserData user, PortalSettings settings, String ipAddress, Action`1 addCustomProperties, Action`1 onAuthenticated)
at DotNetNuke.Authentication.Azure.Components.AzureClient.AuthenticateUser(UserData user, PortalSettings settings, String IPAddress, Action`1 addCustomProperties, Action`1 onAuthenticated)
at DotNetNuke.Services.Authentication.OAuth.OAuthLoginBase.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.<LoadRecursiveAsync>d__246.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Util.WithinCancellableCallbackTaskAwaitable.WithinCancellableCallbackTaskAwaiter.GetResult()
at System.Web.UI.Page.<ProcessRequestMainAsync>d__523.MoveNext()
Source:
FileName:
FileLineNumber:0
FileColumnNumber:0
Method:Anything else?No response Affected Versions10.3.2 (latest release) What browsers are you seeing the problem on?No response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I will move this to a discussion, it is even hard for us to reproduce. This is an SQL index violation so something is trying to maybe insert a duplicate row and I would probably start by debugging that extension first. |
Beta Was this translation helpful? Give feedback.
-
|
After a deeper dive on the code I was able to find the problem on the Auth provider side. I managed to replicate the problem. |
Beta Was this translation helpful? Give feedback.
After a deeper dive on the code I was able to find the problem on the Auth provider side. I managed to replicate the problem.
I have described the problem on the Azure Auth Provider Module here:
davidjrh/dnn.azureadprovider#133