@@ -19,6 +19,9 @@ import (
19
19
"fmt"
20
20
"sort"
21
21
22
+ "github.com/tikv/client-go/v2/internal/logutil"
23
+ "go.uber.org/zap"
24
+
22
25
"github.com/pkg/errors"
23
26
"github.com/tikv/client-go/v2/internal/unionstore/arena"
24
27
"github.com/tikv/client-go/v2/kv"
@@ -84,7 +87,21 @@ type Iterator struct {
84
87
ignoreSeqNo bool
85
88
}
86
89
87
- func (it * Iterator ) Valid () bool { return it .valid && (it .seqNo == it .tree .SeqNo || it .ignoreSeqNo ) }
90
+ func (it * Iterator ) checkSeqNo () {
91
+ if it .seqNo != it .tree .SeqNo && ! it .ignoreSeqNo {
92
+ logutil .BgLogger ().Panic (
93
+ "seqNo mismatch" ,
94
+ zap .Int ("it seqNo" , it .seqNo ),
95
+ zap .Int ("art seqNo" , it .tree .SeqNo ),
96
+ zap .Stack ("stack" ),
97
+ )
98
+ }
99
+ }
100
+
101
+ func (it * Iterator ) Valid () bool {
102
+ it .checkSeqNo ()
103
+ return it .valid
104
+ }
88
105
func (it * Iterator ) Key () []byte { return it .currLeaf .GetKey () }
89
106
func (it * Iterator ) Flags () kv.KeyFlags { return it .currLeaf .GetKeyFlags () }
90
107
func (it * Iterator ) Value () []byte {
@@ -108,9 +125,7 @@ func (it *Iterator) Next() error {
108
125
// iterate is finished
109
126
return errors .New ("Art: iterator is finished" )
110
127
}
111
- if ! it .ignoreSeqNo && it .seqNo != it .tree .SeqNo {
112
- return errors .New (fmt .Sprintf ("seqNo mismatch: iter=%d, art=%d" , it .seqNo , it .tree .SeqNo ))
113
- }
128
+ it .checkSeqNo ()
114
129
if it .currAddr == it .endAddr {
115
130
it .valid = false
116
131
return nil
0 commit comments