Azure Table Storage has missing rows in query result (continuation tokens)

I had a small table of 10 rows where the PartitionKey and RowKey where both unique. After querying this table every few seconds for several months, quite happily, it suddenly started returning only 4 rows. After a sleepless night trying to figure it out, it turns out that any query that doesn’t specify both a partition key and a row key can return a continuation token. I wasn’t specifiying a PartitionKey as I wanted all rows. Azure, in its wisdom, moved my data around (as it is entitled to do) and split the table across storage nodes. Consequently, Azure is now returning 4 rows along with a continuation token for the rest. I had to change my code to handle the tokens. There are a few ways to do this in .NET. Either hard code it yourself or use the TableServiceExtensionMethods.AsTableServiceQuery

If you want to avoid continuation tokens, a query must address a single entity completely.

BEWARE! – If you forget to do this, your code may work today but may fail tomorrow without you having any knowledge or control.

Thanks to Richard for his diagnostics help.

Advertisements