This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 2688edcdbf feat(go/adbc/drivermgr): cancel native statements when the
context is cancelled (#4955)
2688edcdbf is described below
commit 2688edcdbfb21f04cbabb0ca662a4bb6f5fbe680
Author: Matt Topol <[email protected]>
AuthorDate: Fri Nov 6 12:31:01 2026 -0500
feat(go/adbc/drivermgr): cancel native statements when the context is
cancelled (#4955)
Every method in the Go driver manager wrapper ignored its
`context.Context`, and nothing called `AdbcStatementCancel`, so a Go
caller had no way to cooperatively cancel a native driver that was
blocked in execution or while reading the result stream.
This PR:
- Makes `ExecuteQuery`, `ExecuteUpdate` and `ExecuteSchema` call
`AdbcStatementCancel` when their context is cancelled during the native
call. For `ExecuteQuery` this continues for as long as the returned
reader is alive. The watcher is a `context.AfterFunc`, joined when the
call returns or when the reader is exhausted or released; a mutex keeps
it from cancelling after `Close`, and re-executing a statement retires
the previous watcher. Contexts that can't be cancelled don't get a
watcher.
- Returns successful native results as-is even if the context is
cancelled after the call returns, since the work may already be
committed. When a native call fails and the context is done, the error
becomes `StatusCancelled`/`StatusTimeout` and keeps the driver's
message.
---
go/adbc/drivermgr/wrapper.go | 228 ++++++++++++++++++++++++-
go/adbc/drivermgr/wrapper_cancellation_test.go | 226 ++++++++++++++++++++++++
go/adbc/drivermgr/wrapper_sqlite_test.go | 51 ++++++
3 files changed, 496 insertions(+), 9 deletions(-)
diff --git a/go/adbc/drivermgr/wrapper.go b/go/adbc/drivermgr/wrapper.go
index 58ded6350e..8ab367f329 100644
--- a/go/adbc/drivermgr/wrapper.go
+++ b/go/adbc/drivermgr/wrapper.go
@@ -75,8 +75,10 @@ import "C"
import (
"bytes"
"context"
+ "errors"
"strconv"
"sync"
+ "sync/atomic"
"unsafe"
"github.com/apache/arrow-adbc/go/adbc"
@@ -225,6 +227,39 @@ func toAdbcError(code adbc.Status, e *C.struct_AdbcError)
error {
return err
}
+func contextAdbcError(ctx context.Context) error {
+ switch ctx.Err() {
+ case context.Canceled:
+ return adbc.Error{Code: adbc.StatusCancelled, Msg:
context.Canceled.Error()}
+ case context.DeadlineExceeded:
+ return adbc.Error{Code: adbc.StatusTimeout, Msg:
context.DeadlineExceeded.Error()}
+ default:
+ return nil
+ }
+}
+
+func contextDriverError(ctx context.Context, driverErr error) error {
+ ctxErr := ctx.Err()
+ if ctxErr == nil {
+ return driverErr
+ }
+
+ status := adbc.StatusCancelled
+ if ctxErr == context.DeadlineExceeded {
+ status = adbc.StatusTimeout
+ }
+ var adbcErr adbc.Error
+ if errors.As(driverErr, &adbcErr) {
+ if adbcErr.Code == adbc.StatusCancelled || adbcErr.Code ==
status {
+ return driverErr
+ }
+ adbcErr.Code = status
+ adbcErr.Msg = ctxErr.Error() + ": " + adbcErr.Msg
+ return adbcErr
+ }
+ return adbc.Error{Code: status, Msg: ctxErr.Error() + ": " +
driverErr.Error()}
+}
+
// getBufferOption uses the ADBC 1.1 length protocol: the first call writes
// nothing if the buffer is too short and reports the required length.
func getBufferOption(kind C.int, handle unsafe.Pointer, key string, bytes
bool) ([]byte, error) {
@@ -740,18 +775,147 @@ func (c *cnxn) GetOptionDouble(key string) (float64,
error) {
type stmt struct {
st *C.struct_AdbcStatement
+
+ mu sync.Mutex // serializes cancellation and release
+ closed bool
+ active *cancellationWatch
+}
+
+type cancellationWatch struct {
+ stop func() bool
+ done chan struct{}
+ once sync.Once
+}
+
+func (w *cancellationWatch) stopAndJoin() {
+ w.once.Do(func() {
+ // AfterFunc's stop does not wait for an already-started
callback.
+ if !w.stop() {
+ <-w.done
+ }
+ })
+}
+
+func (s *stmt) stopActiveWatch() {
+ s.mu.Lock()
+ old := s.active
+ s.active = nil
+ s.mu.Unlock()
+ if old != nil {
+ old.stopAndJoin()
+ }
+}
+
+func (s *stmt) stopWatching(w *cancellationWatch) {
+ if w == nil {
+ return
+ }
+ s.mu.Lock()
+ if s.active == w {
+ s.active = nil
+ }
+ s.mu.Unlock()
+ w.stopAndJoin()
+}
+
+func (s *stmt) watchCancellation(ctx context.Context) *cancellationWatch {
+ if ctx.Done() == nil {
+ return nil
+ }
+
+ w := &cancellationWatch{done: make(chan struct{})}
+ s.mu.Lock()
+ w.stop = context.AfterFunc(ctx, func() {
+ s.mu.Lock()
+ if !s.closed && s.active == w {
+ var err C.struct_AdbcError
+ C.AdbcStatementCancel(s.st, &err)
+ C.releaseErr(&err) // Cancellation is best-effort,
including NOT_IMPLEMENTED.
+ }
+ s.mu.Unlock()
+ close(w.done)
+ })
+ s.active = w
+ s.mu.Unlock()
+ return w
}
var _ adbc.StatementExecuteSchema = (*stmt)(nil)
func (s *stmt) Close() error {
+ s.stopActiveWatch()
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if s.closed {
+ return nil
+ }
+
var err C.struct_AdbcError
+ s.closed = true // The driver manager invalidates the statement even if
release fails.
if code := adbc.Status(C.AdbcStatementRelease(s.st, &err)); code !=
adbc.StatusOK {
return toAdbcError(code, &err)
}
return nil
}
+type cancellationReader struct {
+ array.RecordReader
+ ctx context.Context
+ stmt *stmt
+ watch *cancellationWatch
+ refs atomic.Int64
+ err error
+}
+
+func (r *cancellationReader) stopWatching() {
+ r.stmt.stopWatching(r.watch)
+}
+
+// Retain and Release count references to the wrapper, which holds a single
+// reference to the underlying reader until its own count reaches zero.
+func (r *cancellationReader) Retain() {
+ r.refs.Add(1)
+}
+
+func (r *cancellationReader) Release() {
+ if r.refs.Add(-1) == 0 {
+ r.stopWatching()
+ r.RecordReader.Release()
+ }
+}
+
+func (r *cancellationReader) Next() bool {
+ if err := contextAdbcError(r.ctx); err != nil {
+ r.err = err
+ // Leave the watcher armed until Release: it must still cancel
the
+ // statement if the callback has not started yet.
+ return false
+ }
+
+ ok := r.RecordReader.Next()
+ if err := contextAdbcError(r.ctx); err != nil {
+ if !ok {
+ if driverErr := r.RecordReader.Err(); driverErr != nil {
+ err = contextDriverError(r.ctx, driverErr)
+ }
+ r.stopWatching()
+ }
+ r.err = err
+ return false
+ }
+ if !ok {
+ r.stopWatching()
+ }
+ return ok
+}
+
+func (r *cancellationReader) Err() error {
+ if r.err != nil {
+ return r.err
+ }
+ return r.RecordReader.Err()
+}
+
func (s *stmt) SetOption(key, value string) error {
return setStringOption(2, unsafe.Pointer(s.st), key, value)
}
@@ -795,45 +959,91 @@ func (s *stmt) SetSqlQuery(query string) error {
return nil
}
-func (s *stmt) ExecuteQuery(context.Context) (array.RecordReader, int64,
error) {
+// ExecuteQuery keeps the execution context active until the reader is released
+// or exhausted, since drivers may block while fetching from the result stream.
+func (s *stmt) ExecuteQuery(ctx context.Context) (array.RecordReader, int64,
error) {
+ s.stopActiveWatch()
+ if err := contextAdbcError(ctx); err != nil {
+ return nil, 0, err
+ }
+
var (
out C.struct_ArrowArrayStream
affected C.int64_t
err C.struct_AdbcError
)
+ watch := s.watchCancellation(ctx)
+ if ctxErr := contextAdbcError(ctx); ctxErr != nil {
+ s.stopWatching(watch)
+ return nil, 0, ctxErr
+ }
code := adbc.Status(C.AdbcStatementExecuteQuery(s.st, &out, &affected,
&err))
if code != adbc.StatusOK {
- return nil, 0, toAdbcError(code, &err)
+ s.stopWatching(watch)
+ if out.release != nil {
+
cdata.ReleaseCArrowArrayStream((*cdata.CArrowArrayStream)(unsafe.Pointer(&out)))
+ }
+ return nil, 0, contextDriverError(ctx, toAdbcError(code, &err))
}
rdr, goerr := getRdr(&out)
if goerr != nil {
+ s.stopWatching(watch)
return nil, int64(affected), goerr
}
- return rdr, int64(affected), nil
+ if watch == nil {
+ return rdr, int64(affected), nil
+ }
+ wrapped := &cancellationReader{RecordReader: rdr, ctx: ctx, stmt: s,
watch: watch}
+ wrapped.refs.Store(1)
+ return wrapped, int64(affected), nil
}
-func (s *stmt) ExecuteUpdate(context.Context) (int64, error) {
+func (s *stmt) ExecuteUpdate(ctx context.Context) (int64, error) {
+ s.stopActiveWatch()
+ if err := contextAdbcError(ctx); err != nil {
+ return -1, err
+ }
+
var (
nrows C.int64_t
err C.struct_AdbcError
)
- if code := adbc.Status(C.AdbcStatementExecuteQuery(s.st, nil, &nrows,
&err)); code != adbc.StatusOK {
- return -1, toAdbcError(code, &err)
+ watch := s.watchCancellation(ctx)
+ if ctxErr := contextAdbcError(ctx); ctxErr != nil {
+ s.stopWatching(watch)
+ return -1, ctxErr
+ }
+ code := adbc.Status(C.AdbcStatementExecuteQuery(s.st, nil, &nrows,
&err))
+ s.stopWatching(watch)
+ if code != adbc.StatusOK {
+ return -1, contextDriverError(ctx, toAdbcError(code, &err))
}
return int64(nrows), nil
}
-func (s *stmt) ExecuteSchema(_ context.Context) (*arrow.Schema, error) {
+func (s *stmt) ExecuteSchema(ctx context.Context) (*arrow.Schema, error) {
+ s.stopActiveWatch()
+ if err := contextAdbcError(ctx); err != nil {
+ return nil, err
+ }
+
var (
schema C.struct_ArrowSchema
err C.struct_AdbcError
)
- if code := adbc.Status(C.AdbcStatementExecuteSchema(s.st, &schema,
&err)); code != adbc.StatusOK {
+ watch := s.watchCancellation(ctx)
+ if ctxErr := contextAdbcError(ctx); ctxErr != nil {
+ s.stopWatching(watch)
+ return nil, ctxErr
+ }
+ code := adbc.Status(C.AdbcStatementExecuteSchema(s.st, &schema, &err))
+ s.stopWatching(watch)
+ if code != adbc.StatusOK {
if schema.release != nil {
cdata.ReleaseCArrowSchema((*cdata.CArrowSchema)(unsafe.Pointer(&schema)))
}
- return nil, toAdbcError(code, &err)
+ return nil, contextDriverError(ctx, toAdbcError(code, &err))
}
return getSchema(&schema)
}
diff --git a/go/adbc/drivermgr/wrapper_cancellation_test.go
b/go/adbc/drivermgr/wrapper_cancellation_test.go
new file mode 100644
index 0000000000..11e11e5a35
--- /dev/null
+++ b/go/adbc/drivermgr/wrapper_cancellation_test.go
@@ -0,0 +1,226 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//go:build cgo
+
+package drivermgr
+
+import (
+ "context"
+ "runtime"
+ "sync/atomic"
+ "testing"
+
+ "github.com/apache/arrow-adbc/go/adbc"
+ "github.com/stretchr/testify/require"
+)
+
+func newSQLiteStatement(t *testing.T) adbc.Statement {
+ t.Helper()
+ db, err := (Driver{}).NewDatabase(map[string]string{"driver":
"adbc_driver_sqlite"})
+ require.NoError(t, err)
+ t.Cleanup(func() { require.NoError(t, db.Close()) })
+
+ conn, err := db.Open(context.Background())
+ require.NoError(t, err)
+ t.Cleanup(func() { require.NoError(t, conn.Close()) })
+
+ st, err := conn.NewStatement()
+ require.NoError(t, err)
+ t.Cleanup(func() { require.NoError(t, st.Close()) })
+ require.NoError(t, st.SetSqlQuery("SELECT 1"))
+ return st
+}
+
+// cancelOnCheck controls when the context is cancelled around a real SQLite
call.
+// For Execute*, the first two Err checks precede the native call.
+type cancelOnCheck struct {
+ context.Context
+ cancel context.CancelFunc
+ at int32
+ checks atomic.Int32
+}
+
+func (c *cancelOnCheck) Err() error {
+ if c.checks.Add(1) == c.at {
+ c.cancel()
+ }
+ return c.Context.Err()
+}
+
+func TestSQLiteUpdateSuccessDespiteLateCancellation(t *testing.T) {
+ st := newSQLiteStatement(t)
+ require.NoError(t, st.SetSqlQuery("CREATE TEMP TABLE update_probe (id
INTEGER)"))
+ _, err := st.ExecuteUpdate(context.Background())
+ require.NoError(t, err)
+ require.NoError(t, st.SetSqlQuery("INSERT INTO update_probe (id) VALUES
(1)"))
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ late := &cancelOnCheck{Context: ctx, cancel: cancel, at: 3}
+ affected, err := st.ExecuteUpdate(late)
+ require.NoError(t, err)
+ require.Equal(t, int64(1), affected)
+ require.ErrorIs(t, late.Err(), context.Canceled)
+}
+
+func TestSQLiteQuerySuccessDespiteLateCancellation(t *testing.T) {
+ st := newSQLiteStatement(t)
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ late := &cancelOnCheck{Context: ctx, cancel: cancel, at: 3}
+
+ rdr, _, err := st.ExecuteQuery(late)
+ require.NoError(t, err)
+ require.NotNil(t, rdr)
+ defer rdr.Release()
+ require.ErrorIs(t, late.Err(), context.Canceled)
+ require.False(t, rdr.Next())
+ var adbcErr adbc.Error
+ require.ErrorAs(t, rdr.Err(), &adbcErr)
+ require.Equal(t, adbc.StatusCancelled, adbcErr.Code)
+}
+
+func TestContextDriverErrorKeepsDriverDetail(t *testing.T) {
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+
+ driverErr := adbc.Error{Code: adbc.StatusInvalidArgument, Msg: "driver
detail", VendorCode: 42}
+ var result adbc.Error
+ require.ErrorAs(t, contextDriverError(ctx, driverErr), &result)
+ require.Equal(t, adbc.StatusCancelled, result.Code)
+ require.Contains(t, result.Msg, driverErr.Msg)
+ require.Equal(t, driverErr.VendorCode, result.VendorCode)
+
+ driverErr.Code = adbc.StatusCancelled
+ require.Equal(t, driverErr, contextDriverError(ctx, driverErr))
+}
+
+func TestSQLiteStatementCancelReaderLifetime(t *testing.T) {
+ st := newSQLiteStatement(t).(*stmt)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ rdr, _, err := st.ExecuteQuery(ctx)
+ require.NoError(t, err)
+ require.NotNil(t, st.active)
+ cancel()
+ require.False(t, rdr.Next())
+ var adbcErr adbc.Error
+ require.ErrorAs(t, rdr.Err(), &adbcErr)
+ require.Equal(t, adbc.StatusCancelled, adbcErr.Code)
+ rdr.Release()
+ require.Nil(t, st.active)
+
+ // Releasing a reader disarms its context before the context is
cancelled.
+ ctxReleased, cancelReleased := context.WithCancel(context.Background())
+ defer cancelReleased()
+ rdr, _, err = st.ExecuteQuery(ctxReleased)
+ require.NoError(t, err)
+ require.NotNil(t, st.active)
+ rdr.Release()
+ require.Nil(t, st.active)
+ cancelReleased()
+
+ // Exhausting a reader also disarms its context without requiring
Release.
+ ctxExhausted, cancelExhausted :=
context.WithCancel(context.Background())
+ defer cancelExhausted()
+ rdr, _, err = st.ExecuteQuery(ctxExhausted)
+ require.NoError(t, err)
+ require.True(t, rdr.Next())
+ require.False(t, rdr.Next())
+ require.NoError(t, rdr.Err())
+ require.Nil(t, st.active)
+ cancelExhausted()
+ rdr.Release()
+}
+
+func TestSQLiteReexecutionRetiresPreviousCancellation(t *testing.T) {
+ st := newSQLiteStatement(t).(*stmt)
+ oldCtx, cancelOld := context.WithCancel(context.Background())
+ defer cancelOld()
+ oldRdr, _, err := st.ExecuteQuery(oldCtx)
+ require.NoError(t, err)
+ defer func() {
+ if oldRdr != nil {
+ oldRdr.Release()
+ }
+ }()
+ oldWatch := st.active
+ require.NotNil(t, oldWatch)
+
+ newCtx, cancelNew := context.WithCancel(context.Background())
+ defer cancelNew()
+ newRdr, _, err := st.ExecuteQuery(newCtx)
+ require.NoError(t, err)
+ defer newRdr.Release()
+ newWatch := st.active
+ require.NotNil(t, newWatch)
+ require.NotSame(t, oldWatch, newWatch)
+
+ cancelOld()
+ require.Same(t, newWatch, st.active)
+ oldRdr.Release()
+ oldRdr = nil
+ require.Same(t, newWatch, st.active, "releasing a stale reader must not
disarm the new execution")
+ require.True(t, newRdr.Next(), "cancelling the stale context must not
affect the new query")
+ require.NoError(t, newRdr.Err())
+ cancelNew()
+ require.False(t, newRdr.Next())
+ var adbcErr adbc.Error
+ require.ErrorAs(t, newRdr.Err(), &adbcErr)
+ require.Equal(t, adbc.StatusCancelled, adbcErr.Code)
+}
+
+func TestSQLiteCancelledReadKeepsDriverDetail(t *testing.T) {
+ st := newSQLiteStatement(t)
+ require.NoError(t, st.SetOption("adbc.sqlite.query.batch_rows", "1"))
+ require.NoError(t, st.SetSqlQuery("SELECT 1 AS value UNION ALL SELECT
'text' AS value"))
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ // SQLite's native StatementCancel is not implemented; arrange for the
+ // context to expire when its real stream reports a second-batch type
error.
+ late := &cancelOnCheck{Context: ctx, cancel: cancel, at: 6}
+ rdr, _, err := st.ExecuteQuery(late)
+ require.NoError(t, err)
+ defer rdr.Release()
+ require.True(t, rdr.Next())
+ require.False(t, rdr.Next())
+ var adbcErr adbc.Error
+ require.ErrorAs(t, rdr.Err(), &adbcErr)
+ require.Equal(t, adbc.StatusCancelled, adbcErr.Code)
+ require.Contains(t, adbcErr.Msg, "Type mismatch")
+}
+
+func TestSQLiteBackgroundExecutionDoesNotWatchCancellation(t *testing.T) {
+ st := newSQLiteStatement(t)
+ before := runtime.NumGoroutine()
+ for range 64 {
+ rdr, _, err := st.ExecuteQuery(context.Background())
+ require.NoError(t, err)
+ _, wrapped := rdr.(*cancellationReader)
+ require.False(t, wrapped, "Background should return the
unwrapped reader")
+ rdr.Release()
+ require.NoError(t, st.SetSqlQuery("CREATE TEMP TABLE IF NOT
EXISTS background_probe (id INTEGER)"))
+ _, err = st.ExecuteUpdate(context.Background())
+ require.NoError(t, err)
+ require.NoError(t, st.SetSqlQuery("SELECT 1"))
+ }
+ runtime.Gosched()
+ require.LessOrEqual(t, runtime.NumGoroutine(), before+4, "background
executions leaked goroutines")
+}
diff --git a/go/adbc/drivermgr/wrapper_sqlite_test.go
b/go/adbc/drivermgr/wrapper_sqlite_test.go
index 6e7573014d..2edffbd02e 100644
--- a/go/adbc/drivermgr/wrapper_sqlite_test.go
+++ b/go/adbc/drivermgr/wrapper_sqlite_test.go
@@ -24,6 +24,7 @@ import (
"runtime"
"strings"
"testing"
+ "time"
"github.com/apache/arrow-adbc/go/adbc"
"github.com/apache/arrow-adbc/go/adbc/drivermgr"
@@ -586,6 +587,56 @@ func (dm *DriverMgrSuite) TestSqlExecute() {
dm.False(rdr.Next())
}
+func (dm *DriverMgrSuite) TestSqlExecutePrecancelled() {
+ st, err := dm.conn.NewStatement()
+ dm.Require().NoError(err)
+ defer validation.CheckedClose(dm.T(), st)
+ dm.Require().NoError(st.SetSqlQuery("SELECT 1"))
+
+ ctx, cancel := context.WithCancel(dm.ctx)
+ cancel()
+
+ rdr, _, err := st.ExecuteQuery(ctx)
+ dm.Nil(rdr)
+ var adbcErr adbc.Error
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusCancelled, adbcErr.Code)
+
+ _, err = st.ExecuteUpdate(ctx)
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusCancelled, adbcErr.Code)
+
+ schema, err := st.(adbc.StatementExecuteSchema).ExecuteSchema(ctx)
+ dm.Nil(schema)
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusCancelled, adbcErr.Code)
+}
+
+func (dm *DriverMgrSuite) TestSqlExecuteExpiredDeadline() {
+ st, err := dm.conn.NewStatement()
+ dm.Require().NoError(err)
+ defer validation.CheckedClose(dm.T(), st)
+ dm.Require().NoError(st.SetSqlQuery("SELECT 1"))
+
+ ctx, cancel := context.WithDeadline(dm.ctx,
time.Now().Add(-time.Second))
+ defer cancel()
+
+ rdr, _, err := st.ExecuteQuery(ctx)
+ dm.Nil(rdr)
+ var adbcErr adbc.Error
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusTimeout, adbcErr.Code)
+
+ _, err = st.ExecuteUpdate(ctx)
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusTimeout, adbcErr.Code)
+
+ schema, err := st.(adbc.StatementExecuteSchema).ExecuteSchema(ctx)
+ dm.Nil(schema)
+ dm.Require().ErrorAs(err, &adbcErr)
+ dm.Equal(adbc.StatusTimeout, adbcErr.Code)
+}
+
func (dm *DriverMgrSuite) TestSqlExecuteSchemaNotImplemented() {
st, err := dm.conn.NewStatement()
dm.Require().NoError(err)