Skip to content

Commit

Permalink
sql: properly log copy error on error
Browse files Browse the repository at this point in the history
This commit fixes an earlier commit by ensuring maybeLogStatement for
copy actually logs the error that comes out of it.

Release justification: bug fix
Release note: None
  • Loading branch information
otan committed Aug 25, 2022
1 parent fe11e4b commit a5c6c84
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/sql/conn_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,7 @@ func (ex *connExecutor) execCopyIn(
payload := eventNonRetriableErrPayload{err: err}
return ev, payload, nil
}
var copyError error
defer func() {
cm.Close(ctx)

Expand All @@ -2455,7 +2456,7 @@ func (ex *connExecutor) execCopyIn(
int(ex.state.mu.autoRetryCounter),
ex.extraTxnState.txnCounter,
cm.numInsertedRows(),
retErr,
copyError,
ex.statsCollector.PhaseTimes().GetSessionPhaseTime(sessionphase.SessionQueryReceived),
&ex.extraTxnState.hasAdminRoleCache,
ex.server.TelemetryLoggingMetrics,
Expand All @@ -2464,9 +2465,9 @@ func (ex *connExecutor) execCopyIn(
)
}()

if err := ex.execWithProfiling(ctx, cmd.Stmt, nil, func(ctx context.Context) error {
if copyError = ex.execWithProfiling(ctx, cmd.Stmt, nil, func(ctx context.Context) error {
return cm.run(ctx)
}); err != nil {
}); copyError != nil {
// TODO(andrei): We don't have a retriable error story for the copy machine.
// When running outside of a txn, the copyMachine should probably do retries
// internally. When not, it's unclear what we should do. For now, we abort
Expand All @@ -2475,7 +2476,7 @@ func (ex *connExecutor) execCopyIn(
// should terminate the connection) from query errors. For now, we treat all
// errors as query errors.
ev := eventNonRetriableErr{IsCommit: fsm.False}
payload := eventNonRetriableErrPayload{err: err}
payload := eventNonRetriableErrPayload{err: copyError}
return ev, payload, nil
}
return nil, nil, nil
Expand Down

0 comments on commit a5c6c84

Please sign in to comment.