13

The log for my IndexWorker is filling up with the following error:

Tokens are incompatible, they have different set of shards

Any ideas what might be causing this?

2 Answers 2

28

Credit to Rob Earlam for helping me find the solution to this.

Essentially, information about the shard databases is stored in the xdb index. If either the server or database name of your shards changes, this will result in this error being logged. In my case, we had cloned (what was now) "production" to be the new "UAT" but the index still referred to the production database server.

To confirm if this is indeed your problem, you can do the following (skip ahead if you're already sure):

In Solr, query the Sitecore_xdb index for id:xdb-index-token. Next, copy the xdbtokenbytes_s value and provide it to the following PowerShell script:

ConvertFrom-XdbIndexToken.ps1

param(
    [string]$Token = (Read-Host "Enter xdbtokenbytes_s value")
)

$bytes = [Convert]::FromBase64String($Token)
$ms = [System.IO.MemoryStream]::new($bytes, 0, $bytes.Length)
$bf = [System.Runtime.Serialization.Formatters.Binary.BinaryFormatter]::new()
$dict = $bf.Deserialize($ms);

Write-Output $dict

It will output something like this:

[DataSource=DBSERVERNAME Database=Sitecore_Xdb.Collection.Shard0] - 1739
[DataSource=DBSERVERNAME Database=Sitecore_Xdb.Collection.Shard1] - 1349

If the indexed values don't match the actual db Server/Database, you'll need to rebuild the XDB index. There is documentation available on how to do this, but it will usually boil down to running the following on your xconnect server:

XConnectSearchIndexer.exe -requestrebuild

Original C# version

If PowerShell isn't an option, here's the equivalent in C#. Run it in a console app (or via a service like .NET Fiddle)

using System;
using System.Collections.Generic;
using System.IO;

public class Program
{
    public static void Main()
    {
        var s = "TOKEN_HERE";
        byte[] bytes = Convert.FromBase64String(s);
        using (var rs = new MemoryStream(bytes, 0, bytes.Length))
        {
            var sf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
            var o = sf.Deserialize(rs) as Dictionary<string, long?>;
            foreach(var kvp in o)
            {
                Console.WriteLine($"{kvp.Key} - {kvp.Value}");
            }
        }
    }
}
2
  • 1
    Im getting the error but my DBSERVERNAME and Database names are correct. any advice?
    – JGilmartin
    Commented Nov 1, 2018 at 15:24
  • @Richard I am also getting the same error. In my case, despite executing the command XConnectSearchIndexer.exe -requestrebuild, solr still points to old shard db server. Any idea how to fix this? Commented May 23, 2023 at 17:27
8

In case this error persists, even after you rebuild the XDB index, you might as well want to check the items under /sitecore/system/List Manager/ListOperations node.

These items are created by the List Manager application and they contain a field named Sync Token. You should update the Sync Token field of each item with the one corresponding to your local instance. These items will eventually disappear as the List Manager process them.

To find out what Sync Token you should use, just do as Richard Szalay suggested above. In Solr, query the [prefix]_xdb index for id:xdb-index-token field.

1
  • I am also getting the same error. In my case, despite executing the command XConnectSearchIndexer.exe -requestrebuild, solr still points to old shard db server. For me the node /sitecore/system/List Manager/ListOperations is empty. Any idea how to fix this? Commented May 23, 2023 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.