apache / apache/iotdb

About refine the exception handling logic in method commitTo in RaftLogManager

オープン
#3,856 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
6.4k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
115

説明

### Discussed in https://github.com/apache/iotdb/discussions/3833

Originally posted by **chengjianyun** August 25, 2021
Hi, all

The discussion started from the issue https://github.com/apache/iotdb/discussions/3784 and https://issues.apache.org/jira/browse/IOTDB-1583. Here we don't talk about how to fix the concrete `BufferOverFlowException`(a pr has been proposed, see https://github.com/apache/iotdb/pull/3832) but how such exception should be handled. We have had some discission offline and let me summary here to let more people join the discussion.

## Background

According to the issue we mentioned above, right now, if some exception is thrown between the code in `RaftLogManager.java`, the raft group would run into a invalid state that can't accept write request anymore. Root cause is that `committedEntries`, `uncommittedEntries` and `commitIndex` are not updated together if some exception happens in the red rectangle which cause the inconsistency between the variables.

![1629887128(1)](https://user-images.githubusercontent.com/6150814/130774200-d709a962-8262-48b4-8c82-68154a103c39.jpg)

## Discussion

I think here we have two different opinions:

1. Tolerant the error in some way and let the data group continue serve
2. Let the node stop serve the data group

### 1. Tolerant the error in some way

Here we may set some NO_OP like action for error entries which could let raft log running forward and keep monotonically increase. And at same time tell the user that these operations are fail.

The drawback is obvious, as the entry has been append to all other nodes in the data group, we can't guarantee all nodes in the group would suffer such runtime exception. So, we can't guarantee the consistency of the nodes in the data group. Of course, for the exceptions like [issue-1583](https://issues.apache.org/jira/browse/IOTDB-1583), all nodes should suffer the same exception and it should finally keep the consistent.

For me, I won' t vote for the solution right now as it can't make sure the consistency. We can talk more about the solution here.

### 2. Let node stop serve the data group

The idea here is to let the node is suffering the exception quit the data group properly so that other group members may continue work. The solution could tolerant the exception just happen on some of nodes and keep the server's availability. But for the [issue-1583](https://issues.apache.org/jira/browse/IOTDB-1583), finally all nodes will quit the group cause the service down.

This is a conservative policy, which is much safe to apply. And in etcd, if the storage have error, it will stop serve write operation as show in comments in file [storage.go](https://github.com/etcd-io/etcd/blob/27fc7e2296f506182f58ce846e48f36b34fe6842/raft/storage.go#L40-L45).

```
// Storage is an interface that may be implemented by the application
// to retrieve log entries from storage.
//
// If any Storage method returns an error, the raft instance will
// become inoperable and refuse to participate in elections; the
// application is responsible for cleanup and recovery in this case.
type Storage interface {
...
```
Here, I like the solution right now because it won't cause very big change and doesn't cause side effect.

Your ideas and comments are welcome.

Thanks!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

RaftLogManager.java と commitTo メソッドから始め、次に discussions 3833 と 3784、およびリンクされている Jira issue IOTDB-1583 を読んでください。提案されている 2 つの例外処理ポリシーと、etcd storage.go のリファレンスを比較してください。この issue は、プロジェクトがポリシーについて合意し、committedEntries、uncommittedEntries、commitIndex の結果として生じる動作を定義した後にのみ完了します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
databases, distributed-systems
issue の種類
リファクタリング
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。