Service Fabric 有状态服务如何避免 InvalidOperationException on long 运行 transaction with large values

Service Fabric Statefull Service how to avoid InvalidOperationException on long running transaction with large values

我有一个相当长的 运行 事务,它更新多个可靠集合的大值(字典)。我将 运行 保留为 InvalidOperationExceptions(事务正在提交或回滚),重试该操作只会再次导致异常。我能做些什么来缓解这个问题吗?

我认为这与文档中所说的事务日志的事务阻塞截断有关。使日志变大或变小会有帮助吗?

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-reliable-collections-guidelines

Do handle InvalidOperationException. User transactions can be aborted by the system for variety of reasons. For example, when the Reliable State Manager is changing its role out of Primary or when a long-running transaction is blocking truncation of the transactional log. In such cases, user may receive InvalidOperationException indicating that their transaction has already been terminated. Assuming, the termination of the transaction was not requested by the user, best way to handle this exception is to dispose the transaction, check if the cancellation token has been signaled (or the role of the replica has been changed), and if not create a new transaction and retry.

我不确定是哪个设置完成的,但我使用以下

        new ReliableStateManagerConfiguration(new ReliableStateManagerReplicatorSettings
        {
            CheckpointThresholdInMB = 4096,
            MaxRecordSizeInKB = 1024 * 1024,
            MinLogSizeInMB = 4096,
        })))

认为增加 MinLogSizeInMB 会阻止它在事务期间由于值较大而尝试截断日志。

不幸的是,这只允许完成一个事务。最终,日志必须被截断,并且当发生这种情况时,任何正在进行的事务都会失败,并且必须重试。如果有办法解决这个问题就好了。我很想使 MinLogSizeInMB 成为一个巨大的数字,以使这些错误尽可能少。