hcrosse commented on code in PR #2673:
URL: https://github.com/apache/iceberg-go/pull/2673#discussion_r4646787299
##########
table/mor_delete_conflict_test.go:
##########
@@ -198,3 +203,166 @@ func
TestMergeOnReadDeleteOfDataFileAddedInSameTransaction(t *testing.T) {
require.Equal(t, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12},
idsInTable(t, tbl))
}
+
+type failPuffinOpenIO struct{ iceio.LocalFS }
+
+func (f failPuffinOpenIO) Open(ctx context.Context, name string) (iceio.File,
error) {
+ if strings.HasSuffix(name, ".puffin") {
+ return nil, errors.New("puffin read failed")
+ }
+
+ return f.LocalFS.Open(ctx, name)
+}
+
+func deleteScanGoroutines() (scan, sequencer int) {
+ var b strings.Builder
+ _ = pprof.Lookup("goroutine").WriteTo(&b, 2)
+ for g := range strings.SplitSeq(b.String(), "\n\n") {
+ if strings.Contains(g, "makePositionDeleteRecordsForFilter") {
+ scan++
+ }
+ if strings.Contains(g, "MakeSequencedChanWithDiscard") {
+ sequencer++
+ }
+ }
Review Comment:
`pprof.Lookup("goroutine").WriteTo(&b, 2)` writes to a `*strings.Builder`,
whose `Write` method always returns a nil error, and `debug=2` dumps
`runtime.Stack` directly to the writer.
##########
table/mor_delete_conflict_test.go:
##########
@@ -198,3 +203,166 @@ func
TestMergeOnReadDeleteOfDataFileAddedInSameTransaction(t *testing.T) {
require.Equal(t, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12},
idsInTable(t, tbl))
}
+
+type failPuffinOpenIO struct{ iceio.LocalFS }
+
+func (f failPuffinOpenIO) Open(ctx context.Context, name string) (iceio.File,
error) {
+ if strings.HasSuffix(name, ".puffin") {
+ return nil, errors.New("puffin read failed")
+ }
+
+ return f.LocalFS.Open(ctx, name)
+}
+
+func deleteScanGoroutines() (scan, sequencer int) {
+ var b strings.Builder
+ _ = pprof.Lookup("goroutine").WriteTo(&b, 2)
+ for g := range strings.SplitSeq(b.String(), "\n\n") {
+ if strings.Contains(g, "makePositionDeleteRecordsForFilter") {
+ scan++
+ }
+ if strings.Contains(g, "MakeSequencedChanWithDiscard") {
+ sequencer++
+ }
+ }
+
+ return scan, sequencer
+}
+
+// A v3 merge-on-read delete whose deletion-vector read fails must not leave a
+// scan behind. Not parallel, so other tests' scans don't count.
+func TestMergeOnReadDeleteDVReadErrorStopsScan(t *testing.T) {
+ ctx := t.Context()
+ tbl := appendTenRows(t, newV3MoRConflictTestTable(t))
+ tbl, err := tbl.Delete(ctx, iceberg.EqualTo(iceberg.Reference("id"),
int64(1)), nil)
+ require.NoError(t, err)
+
+ failing := table.New(tbl.Identifier(), tbl.Metadata(),
tbl.MetadataLocation(),
+ func(context.Context) (iceio.IO, error) { return
failPuffinOpenIO{}, nil }, nil)
+ scanBefore, seqBefore := deleteScanGoroutines()
+ err = failing.NewTransaction().Delete(ctx,
iceberg.EqualTo(iceberg.Reference("id"), int64(3)), nil)
+ require.ErrorContains(t, err, "puffin read failed")
+ scanAfter, seqAfter := deleteScanGoroutines()
+ require.LessOrEqual(t, scanAfter, scanBefore)
+ require.LessOrEqual(t, seqAfter, seqBefore)
Review Comment:
With the lazy start, no scan or sequencer goroutines are started at all
before the DV read or writer check fails, so there is nothing unwinding to wait
for.
##########
table/transaction_delete.go:
##########
@@ -1121,62 +1121,65 @@ func (t *Transaction)
makePositionDeleteRecordsForFilter(ctx context.Context, fs
return nil, err
}
- deletesPerFile, err := readAllDeleteFiles(ctx, fs, tasks, concurrency)
- if err != nil {
- // readAllDeleteFiles can return a partially-populated map
alongside
- // the error if some goroutines completed before the failure.
- releasePerFilePosDeletes(deletesPerFile)
+ return func(yield func(arrow.RecordBatch, error) bool) {
+ deletesPerFile, err := readAllDeleteFiles(ctx, fs, tasks,
concurrency)
+ if err != nil {
+ // readAllDeleteFiles can return a partially-populated
map alongside
+ // the error if some goroutines completed before the
failure.
+ releasePerFilePosDeletes(deletesPerFile)
+ yield(nil, err)
Review Comment:
The next statement is `return`, so `yield` is never called again regardless
of its return value. This satisfies the `iter.Seq2` contract directly without
an extra branch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]