Skip to content

Commit 2913606

Browse files
committed
sstable: fix swallowed errors
In 0bd9d12 I missed a couple of call sites that should propagate errors.
1 parent 0f6a780 commit 2913606

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

sstable/layout.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,9 @@ func (w *layoutWriter) Finish() (size uint64, err error) {
934934
} else {
935935
bw := rowblk.Writer{RestartInterval: 1}
936936
for _, h := range w.handles {
937-
bw.AddRaw(unsafe.Slice(unsafe.StringData(h.key), len(h.key)), h.encodedBlockHandle)
937+
if err := bw.AddRaw(unsafe.Slice(unsafe.StringData(h.key), len(h.key)), h.encodedBlockHandle); err != nil {
938+
return 0, err
939+
}
938940
}
939941
b = bw.Finish()
940942
}

sstable/rowblk/rowblk_iter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ func TestBlockSyntheticPrefix(t *testing.T) {
286286
"pear", "persimmon",
287287
}
288288
for _, k := range keys {
289-
elidedPrefixWriter.Add(ikey(k), nil)
290-
includedPrefixWriter.Add(ikey(prefix+k), nil)
289+
require.NoError(t, elidedPrefixWriter.Add(ikey(k), nil))
290+
require.NoError(t, includedPrefixWriter.Add(ikey(prefix+k), nil))
291291
}
292292

293293
elidedPrefixBlock, includedPrefixBlock := elidedPrefixWriter.Finish(), includedPrefixWriter.Finish()

sstable/rowblk_writer.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,13 @@ func (i *indexBlockBuf) shouldFlush(
327327
int(nEntries), flushGovernor)
328328
}
329329

330-
func (i *indexBlockBuf) add(key InternalKey, value []byte, inflightSize int) {
331-
i.block.Add(key, value)
330+
func (i *indexBlockBuf) add(key InternalKey, value []byte, inflightSize int) error {
331+
if err := i.block.Add(key, value); err != nil {
332+
return err
333+
}
332334
size := i.block.EstimatedSize()
333335
i.size.estimate.writtenWithTotal(uint64(size), inflightSize)
336+
return nil
334337
}
335338

336339
func (i *indexBlockBuf) finish() []byte {
@@ -1180,9 +1183,7 @@ func (w *RawRowWriter) addIndexEntry(
11801183
return err
11811184
}
11821185
}
1183-
1184-
writeTo.add(sep, encoded, inflightSize)
1185-
return nil
1186+
return writeTo.add(sep, encoded, inflightSize)
11861187
}
11871188

11881189
func (w *RawRowWriter) addPrevDataBlockToIndexBlockProps() {

0 commit comments

Comments
 (0)