问题描述
我有两个天蓝色函数
- 一个人从表存储(readFunction)中获取一条新记录
- 将第二个更新表存储更新为已处理(updateFunction)
两个函数都调用以下函数:
public static async Task UpdateMessage(CloudTable table,string partitionKey,string rowKey,JobUpdateStatus updateToStatus)
{
TableOperation retrieve = TableOperation.Retrieve<MigrationFeatures>(partitionKey,rowKey);
TableResult result = await table.ExecuteAsync(retrieve);
MigrationFeatures newMigrationData = (MigrationFeatures)result.Result;
if (result != null)
{
var entity = new DynamicTableEntity(newMigrationData.PartitionKey,newMigrationData.RowKey);
entity.ETag = "*";
entity.Timestamp = DateTime.Now;
entity.Properties.Add("JobStatus",new EntityProperty(updateToStatus.ToString()));
var mergeOperation = TableOperation.Merge(entity);
var tableResult = await table.ExecuteAsync(mergeOperation);
var resultUpdate= tableResult.HttpStatusCode; // returns 204
}
}
现在,我的readFunction查询表存储以获取下一个作业,然后在上面调用此函数。 从准备到完成第一次设置。但是,下次再次转到readFunction时,它将拾取具有原始状态的相同记录,并导致该过程重复。
为什么?
更新屏幕截图 [![在此处输入图片描述] [1]] [1]
一旦流程通过第二个功能,流程将进入“已完成”,一旦碰到第一个功能,数据将在处理中更新回 [1]:https://i.stack.imgur.com/yjFDO.png
更新2:
使用Table.Replace
而不是Table.Merge
选项时,数据开始更新,但是丢失了一半数据(空值)
解决方法
问题很简单,数据已经存储但没有及时复制以供我阅读。
添加延迟已解决问题