Skip to content

Avoid explicit cancellation in single-row cleanup - #2220

Open
HengYpinn wants to merge 1 commit into
DapperLib:mainfrom
HengYpinn:fix/query-row-provider-neutral-cleanup
Open

Avoid explicit cancellation in single-row cleanup#2220
HengYpinn wants to merge 1 commit into
DapperLib:mainfrom
HengYpinn:fix/query-row-provider-neutral-cleanup

Conversation

@HengYpinn

Copy link
Copy Markdown

Summary

  • stop explicitly calling IDbCommand.Cancel() from synchronous single-row query cleanup
  • continue disposing the reader, command, parameters, and connection through the existing cleanup path
  • add regression coverage for both zero-row and multiple-row QuerySingle failures

Root cause

QueryRowImpl explicitly cancelled an open reader whenever the method exited through an exception. This differs from QueryRowAsync, which relies on reader disposal. Some providers treat cancellation as a separate server operation; Oracle can surface ORA-01013 and obscure the meaningful zero-row or multiple-row exception.

Reader disposal is the provider-owned cleanup mechanism and keeps this path provider-neutral. Other command ownership paths, including unbuffered queries and QueryMultiple, are unchanged.

User impact

Single-row query failures retain their expected exception semantics without triggering provider-specific cancellation behavior. Resource cleanup remains intact.

Validation

  • regression test verified red before the fix: both cases recorded an explicit cancellation
  • targeted tests pass on net481, net8.0, and net10.0
  • dotnet build Build.csproj -c Release /p:CI=true --no-restore succeeds
  • full net10.0 test suite: 762 passed, 29 expected skips, 0 failed

Fixes #2215

@HengYpinn
HengYpinn marked this pull request as ready for review August 12, 2026 08:16
@HengYpinn
HengYpinn force-pushed the fix/query-row-provider-neutral-cleanup branch from 31698f7 to 5331cff Compare August 12, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmd.Cancel() in QueryRowImpl finally block causes ORA-1013 on Oracle Database Queries

1 participant