Try our conversational search powered by Generative AI!

LastValue grows for table PK_tblUniqueSequence and get arithematic exception episerver 6

Vote:
 

 The LastValue för PageFolderID in table dbo.tblUniqueSequence grows very big and then this exeption comes

Arithmetic overflow error converting expression to data type int. Violation of PRIMARY KEY constraint 'PK_tblUniqueSequence'. Cannot insert duplicate key in object 'dbo.tblUniqueSequence'. The duplicate key value is (PageFolderID). Arithmetic overflow error converting expression to data type int. The statement has been terminated. The statement has been terminated. The statement has been terminated.

Tried setting LastValue to a low value but it raises very fast and then it crash agaon

This issue was there on episerver 5 R2 but we this issue on episerver 6 . Anyone faced this issue before.

#150768
Jun 29, 2016 11:01
Vote:
 

Hi, 

Have seen this issue couple of times before (bad implementation). A workaround that has worked involves running a sql query to update tblUniqueSequence. Please do a DB backup before attempting this query and try it in a test environment, if possible, first:


UPDATE tbluniquesequence   

      SET tbluniquesequence.LastValue = (select max(tblPage.ExternalFolderID)+1 from tblPage)   

FROM tbluniquesequence,tblPage   

WHERE

tbluniquesequence.Name = 'PageFolderID'

#150794
Jun 29, 2016 13:06
Vote:
 

Yes already doing that , updating LastValue to min value but the value is increasing again and site crashes in like 2 hours or so . 

You said bad implementation , I am unable to figure out the possible cause of it .

Can you point possible cause of it?

Thanks a lot for reply!!.

#150801
Jun 29, 2016 13:13
Vote:
 
After debugging my colleague found out that EPiServer.DataFactory.Instance.GetDefaultPageData(..) was the issue as it create a new empty page(which in turn increments the LastValue)
 
We modified the code and changed to: -

            var pageType = PageType.Load(PageTypeID);
            var definatinPageType= pageType.Definitions.FirstOrDefault(d => d.Name == "Property");
#150888
Jul 01, 2016 10:41
Vote:
 

Ok, so you used GetDefaultPageData somewhere when you only wanted to check some values on a pagetype? 

That one should only be used when creating new pages...

#150890
Jul 01, 2016 11:06
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.