FabricNotReadableException是什么意思?我们应该如何应对呢? [英] What does the FabricNotReadableException mean? And how should we respond to it?

查看:76
本文介绍了FabricNotReadableException是什么意思?我们应该如何应对呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在Service-Fabric上的有状态服务中使用以下方法.该服务具有分区.有时,我们从这种和平的代码中得到FabricNotReadableException.

We are using the following method in a Stateful Service on Service-Fabric. The service has partitions. Sometimes we get a FabricNotReadableException from this peace of code.

public async Task HandleEvent(EventHandlerMessage message)
{
    var queue = await StateManager.GetOrAddAsync<IReliableQueue<EventHandlerMessage>>(EventHandlerServiceConstants.EventHandlerQueueName);
    using(ITransaction tx = StateManager.CreateTransaction())
    {
      await queue.EnqueueAsync(tx, message);
      await tx.CommitAsync();
    }
}

这是否意味着该分区已关闭并且正在移动?其中,我们打了二级分区?因为在某些情况下还会引发FabricNotPrimaryException.

Does that mean that the partition is down and is being moved? Of that we hit a secondary partition? Because there is also a FabricNotPrimaryException that is being raised in some cases.

我已经看到了MSDN链接( https://msdn.microsoft.com/zh-CN/library/azure/system.fabric.fabricnot可读exception.aspx ).

I have seen the MSDN link (https://msdn.microsoft.com/en-us/library/azure/system.fabric.fabricnotreadableexception.aspx). But what does

表示当分区无法接受读取时引发的异常.

Represents an exception that is thrown when a partition cannot accept reads.

是什么意思?分区无法接受读取会发生什么情况?

mean? What happened that a partition cannot accept a read?

推荐答案

在幕后,Service Fabric具有多个状态,这些状态可能会影响给定副本是否可以安全地提供读写服务.他们是:

Under the covers Service Fabric has several states that can impact whether a given replica can safely serve reads and writes. They are:

  • 已授予(您可以将其视为正常操作)
  • 不是主要的
  • 没有写法定人数(同样主要影响写)
  • 正在等待重新配置

FabricNotPrimaryException可以在当前不是主副本的副本上尝试写入并映射到NotPrimary状态时引发.

FabricNotPrimaryException which you mention can be thrown whenever a write is attempted on a replica which is not currently the Primary, and maps to the NotPrimary state.

FabricNotReadableException映射到其他状态(您实际上不必担心或区分它们),并且可以在多种情况下发生.一个示例是,如果您尝试执行读操作的副本是待机"副本(已关闭且已恢复,但副本集中已经有足够活动副本的副本).另一个示例是,如果副本是主副本但正在关闭(例如由于升级或报告故障),或者副本当前正在重新配置(例如正在添加另一个副本).所有这些条件将导致副本由于某些安全检查和Service Fabric需要在引擎盖下处理的原子性更改而无法在短时间内满足写操作.

FabricNotReadableException maps to the other states (you don't really need to worry or differentiate between them), and can happen in a variety of cases. One example is if the replica you are trying to perform the read on is a "Standby" replica (a replica which was down and which has been recovered, but there are already enough active replicas in the replica set). Another example is if the replica is a Primary but is being closed (say due to an upgrade or because it reported fault), or if it is currently undergoing a reconfiguration (say for example that another replica is being added). All of these conditions will result in the replica not being able to satisfy writes for a small amount of time due to certain safety checks and atomic changes that Service Fabric needs to handle under the hood.

您可以考虑FabricNotReadableException可重试.如果看到它,只需再次尝试调用,最终它将解析为NotPrimary或​​Granted.如果收到FabricNotPrimary异常,通常应将此异常扔回客户端(或以某种方式通知客户端),该客户端需要重新解析才能找到当前的Primary(Service Fabric附带的默认通信堆栈)监视不可恢复的异常并代表您重新解决.)

You can consider FabricNotReadableException retriable. If you see it, just try the call again and eventually it will resolve into either NotPrimary or Granted. If you get FabricNotPrimary exception, generally this should be thrown back to the client (or the client in some way notified) that it needs to re-resolve in order to find the current Primary (the default communication stacks that Service Fabric ships take care of watching for non-retriable exceptions and re-resolving on your behalf).

FabricNotReadableException当前有两个已知问题.

There are two current known issues with FabricNotReadableException.

  1. FabricNotReadableException应该具有两个变体.第一个应该是显式可重试(FabricTransientNotReadableException),第二个应该是FabricNotReadableException.第一个版本(Transient)是最常见的版本,可能是您遇到的问题,在大多数情况下肯定是您遇到的问题.如果您最终与Standby副本通话,则会返回第二个(非瞬态).开箱即用的传输和重试逻辑不会发生与备用数据库的对话,但是如果您有自己的语言,则有可能碰到它.
  2. 另一个问题是,今天FabricNotReadableException应该从FabricTransientException派生,这使得更容易确定什么是正确的行为.

这篇关于FabricNotReadableException是什么意思?我们应该如何应对呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆