Skip to content

Commit 7faf0e1

Browse files
committed
fix: return error if the first fillBatch fails
Signed-off-by: ekexium <[email protected]>
1 parent e672ef4 commit 7faf0e1

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

internal/unionstore/arena/arena.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ package arena
3636

3737
import (
3838
"encoding/binary"
39-
"math"
40-
4139
"github.com/tikv/client-go/v2/internal/logutil"
42-
"go.uber.org/zap"
43-
4440
"github.com/tikv/client-go/v2/kv"
4541
"go.uber.org/atomic"
42+
"go.uber.org/zap"
43+
"math"
4644
)
4745

4846
const (

internal/unionstore/memdb_art.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package unionstore
1717
import (
1818
"context"
1919
"fmt"
20-
"go.uber.org/zap"
2120
"sync"
2221

2322
"github.com/tikv/client-go/v2/internal/logutil"
@@ -204,6 +203,7 @@ type snapshotBatchedIter struct {
204203
lower []byte
205204
upper []byte
206205
reverse bool
206+
err error
207207

208208
// current batch
209209
keys [][]byte
@@ -230,10 +230,7 @@ func (db *artDBWithContext) BatchedSnapshotIter(lower, upper []byte, reverse boo
230230
}
231231

232232
iter.snapshot = db.GetSnapshot()
233-
err := iter.fillBatch()
234-
if err != nil {
235-
logutil.BgLogger().Error("failed to fill batch for snapshotBatchedIter", zap.Error(err))
236-
}
233+
iter.err = iter.fillBatch()
237234
return iter
238235
}
239236

@@ -325,10 +322,14 @@ func (it *snapshotBatchedIter) fillBatch() error {
325322

326323
func (it *snapshotBatchedIter) Valid() bool {
327324
return it.snapshotTruncateSeqNo == it.db.SnapshotSeqNo &&
328-
it.pos < len(it.keys)
325+
it.pos < len(it.keys) &&
326+
it.err == nil
329327
}
330328

331329
func (it *snapshotBatchedIter) Next() error {
330+
if it.err != nil {
331+
return it.err
332+
}
332333
if it.snapshotTruncateSeqNo != it.db.SnapshotSeqNo {
333334
return errors.New(
334335
fmt.Sprintf(

internal/unionstore/union_store.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ func (us *KVUnionStore) SetEntrySizeLimit(entryLimit, bufferLimit uint64) {
162162
us.memBuffer.SetEntrySizeLimit(entryLimit, bufferLimit)
163163
}
164164

165-
type KvPair struct {
166-
Key []byte
167-
Value []byte
168-
}
169-
170165
// MemBuffer is an interface that stores mutations that written during transaction execution.
171166
// It now unifies MemDB and PipelinedMemDB.
172167
// The implementations should follow the transaction guarantees:

tikv/unionstore_export.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,3 @@ type MemDBCheckpoint = unionstore.MemDBCheckpoint
6060

6161
// Metrics is the metrics of unionstore.
6262
type Metrics = unionstore.Metrics
63-
64-
type KvPair = unionstore.KvPair

0 commit comments

Comments
 (0)