Windows 1252 Encoding breaks Shredded Storage/Cobalt in 2010 to 2013 Upgrades

I have several tools to test if an upgrade is successful and one of those tools hits every webpage and executes every web part on each page and then reports any errors.  I feed this data into a database that can be queried using Excel/PowerPivot.  I noticed an error that was showing rather frequently in the reporting:

Cannot complete this action. Please try again.

When looking at the ULS logs, you will find this:

12/17/2014 18:47:39.08     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Cobalt                            aintx    High        Failed in
CobaltStream.LockBytes: ErrorException — Error: Unknown
(Win32=0x80004003)
— Error message: System.NullReferenceException: Object reference not
set to an instance of an object. 
    at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocParams(SqlSession
session, Guid guidSiteId, Int32 cbContent,
Nullable`1 parentId, Guid docId, Nullable`1 level, SPChunkedArray`1
rgbContent, Byte[] rgbRbsId, Int64 bsn, Byte partition, Int32 pageSize,
Boolean bStartFilling)     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamParams(SqlSession
session,
Guid guidSiteId, Int32 cbContent, Guid docId, SPChunkedArray`1
rgbContent, Byte[] rgbRbsId, Int64 bsn, Byte partition, Boolean
bStartFilling)     at Microsoft….   
7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.08*    w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Cobalt                            aintx    High       
…SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamRowset(SqlSession
session,
SqlDataReader dr, Boolean startFilling, Nullable`1 newSiteId,
SPDocumentStreamResult& stmResult)     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamRowset(SqlSession
session, SqlDataReader dr, Boolean
startFilling, SPDocumentStreamResult& stmResult)     at
Microsoft.SharePoint.SPFileStreamStore.GetBlobsAfterBSN(Int64 bsnAfter,
Nullable`1 typeFilter, Boolean doConsistencyCheck, Boolean&
moreBlobs, Boolean allowExpiredBlobs, Nullable`1 quotaInBytes,
Nullable`1
typeLEQFilter, Nullable`1 typeGEQFilter, DisposalEscrow dispEsc)     at
Microsoft.SharePoint.SPFileStreamHostBlobStore.ExecuteQuery(IEnumerable`1
queries) —> System.NullRefer…   
7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.08*    w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Cobalt                            aintx    High        …enceException:
Object reference not set to an instance of an object.     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocParams(SqlSession
session,
Guid guidSiteId, Int32 cbContent, Nullable`1 parentId, Guid docId,
Nullable`1 level, SPChunkedArray`1 rgbContent, Byte[] rgbRbsId, Int64
bsn, Byte partition, Int32 pageSize, Boolean bStartFilling)     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamParams(SqlSession
session,
Guid guidSiteId, Int32 cbContent, Guid docId, SPChunkedArray`1
rgbContent, Byte[] rgbRbsId, Int64 bsn, Byte partition, Boolean
bStartFilling)     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamRowset(SqlSession
session,
SqlDataRead…    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.08*    w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Cobalt                            aintx    High        …er dr, Boolean
startFilling, Nullable`1 newSiteId, SPDocumentStreamResult&
stmResult)    
at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromStreamRowset(SqlSession
session, SqlDataReader dr, Boolean startFilling,
SPDocumentStreamResult& stmResult)     at
Microsoft.SharePoint.SPFileStreamStore.GetBlobsAfterBSN(Int64
bsnAfter, Nullable`1 typeFilter, Boolean doConsistencyCheck,
Boolean& moreBlobs, Boolean allowExpiredBlobs, Nullable`1
quotaInBytes, Nullable`1 typeLEQFilter, Nullable`1 typeGEQFilter,
DisposalEscrow dispEsc)     at
Microsoft.SharePoint.SPFileStreamHostBlobStore.ExecuteQuery(IEnumerable`1
queries)    
— End of inner exception stack trace —  at   at
Microsoft.SharePoint.SPFileStreamHostBlobStore.ExecuteQuery(IEnumerable`1
queries)     …    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.08*    w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Cobalt                            aintx    High        …at
Cobalt.HostBlobStorePullCommit.ExecuteQuery(IEnumerable`1 queries)    
at
Cobalt.CobaltFilePartition.StreamBlobSchemaHandler.EnsureReadSingleBlob()    
at

Cobalt.CobaltFilePartition.StreamBlobSchemaHandler.GetStream(ExtendedGuid
streamId)     at
Microsoft.SharePoint.CobaltStream.SetPrivateLockBytes()     at
Microsoft.SharePoint.CobaltStream.ConfigureShredded(HostBlobStore
hostBlobStore, IHostBlobStoreUpdateCallback
callback, Schema schema, Boolean cellSchemaIsGenericFda, UInt64
currentStreamLength, Boolean isTocFile)     at
Microsoft.SharePoint.CobaltStream.EnsureStreamConfigured(Boolean
isWrite)     at Microsoft.SharePoint.CobaltStream.Stat(STATSTG&
statStorage, STATFLAG
flags)    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Database                          ab1a9    High        Failed to get
document content data. System.NullReferenceException: Object reference
not
set to an instance of an object. 
    at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocParams(SqlSession
session, Guid guidSiteId, Int32 cbContent, Nullable`1 parentId, Guid
docId, Nullable`1 level, SPChunkedArray`1
rgbContent, Byte[] rgbRbsId, Int64 bsn, Byte partition, Int32 pageSize,
Boolean bStartFilling)     at
Microsoft.SharePoint.CoordinatedStreamBuffer.SPCoordinatedStreamBufferFactory.CreateFromDocumentRowset(Guid
databaseId, SqlSession session, SPFileStreamManager
spfstm, Object[] metadataRow, SPRowset contentRowset,
SPDocumentBindRequest& dbreq, SPDocumentBindResults& dbres)    
at Microsoft.SharePoint.SPSqlClient.GetDocumentContentRow(Int32
rowOrd,…    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13*    w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Database                          ab1a9    High        … Object
ospFileStmMgr, SPDocumentBindRequest& dbreq,
SPDocumentBindResults& dbres)   
7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Files                             abq2i    High        Could not get
DocumentContent row: 0x80004003.
    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Files                             aiv4w    Medium      Spent 0 ms to
bind -1 byte file stream 
   7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
Files                             ahm9p    High       
VhttpManager::getPageText has bad stream length for
/Teamworks/Sites4/40060/SubPages/SNP.aspx   
7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

12/17/2014 18:47:39.13     w3wp.exe (0x04F4)                          
0x1040    SharePoint Foundation            
General                           8kh7    High        Cannot complete
this action.  Please try again.    7fd7d69c-03d1-30ce-5edd-eb2d7d48e92d

So what is it? 

In the upgrade, anything that is tagged as Windows 1252 encoding is not properly converted into a shred.  You will find that the shreds for those files have a NULL Content column.

How did this happen? 

These files are typically from 2007 era days and if you have moved from 2003/2007 to 2010 and now to 2013, you will experience this issue.

How do you fix this? 

You have to open all the files in 2010, download the contents, then re-upload so the page is re-encoded to 65001 encoding.  How do you find all the files?  You can run this query across all your content databases to find the improperly coded files:

select *
from alldocs ad with (nolock)
where
extensionforfile = 'aspx'
and charset = 1252
order by dirname, leafname

This will give you all the files that will fail to upgrade to 2013. NOTE:  You are not told that the files failed to upgrade in the upgrade process.  If you have already upgraded to 2013 and are outside your rollback window, you'll have to hope you can get the files from an archive and then restore them manually.

Enjoy!
Chris

Action 15.0.14.0 of Microsoft.Office.Server.Upgrade.ProfileDatabaseSequence failed

You may run into this error when upgrading your UserProfile database.  I had to track this down using Reflector and some database sleuthing.  

Turns out, some people created groups on their mysite and put several people into it.  Any groups created like this (which I had two) will cause this error.  You can get the group id and my site location by finding the third value in the duplicate key value (in this case 20795) and can be found by using the "MemberGroup" table.  You can simply delete this faulty group and then the upgrade will proceed.

12/09/2014 19:36:57.06    powershell (0x245C)    0x3204    SharePoint Foundation Upgrade    ProfileDatabaseSequence    ajywk    INFO    ProfileDatabase Name=Profile_DB    4ed7d9fe-19a3-47a2-b5cb-8f9981bcc813
12/09/2014 19:36:57.06    powershell (0x245C)    0x3204    SharePoint Foundation Upgrade    ProfileDatabaseSequence    ajywk    ERROR    Exception: Violation of UNIQUE KEY constraint 'AK_UserMemberships_RecordId_MemberGroupId_SID'. Cannot insert duplicate key in object 'dbo.UserMemberships'. The duplicate key value is (0c37852b-34d0-418e-91c6-2ac25af4be5b, 21236, 20795, 0x010500000000000515000000b4b7cd221ed1xxxx).  The statement has been terminated.    4ed7d9fe-19a3-47a2-b5cb-8f9981bcc813

Enjoy!
Chris