You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Curious bug with transaction and dbSendQuery() #424
Confirmed with Postgres 14 and 15 on macOS aarch64, built with client 14.5.
Reprex that uses simpler libpq calls under the hood, with variants:
con<-DBI::dbConnect(RPostgres::Postgres())
write_table<-function(n) {
DBI::dbWriteTable(
con,
"df_x",
tibble::tibble(x=1:n),
temporary=TRUE,
overwrite=TRUE
)
}
# Install with `R_PLOGR_ENABLE=1 R CMD INSTALL .` to enable the code below# init_logging("VERB")DBI::dbBegin(con)
# Setup
write_table(2e3)
res<-DBI::dbSendQuery(con, "SELECT * FROM df_x", immediate=TRUE)
# Also causes failure with:# res <- DBI::dbSendQuery(con, "SELECT * FROM df_x")invisible(DBI::dbFetch(res, n=500))
# Also causes failure with:# invisible(DBI::dbFetch(res, n = 0))# invisible(DBI::dbFetch(res, n = 1))# Successful with:# invisible(DBI::dbFetch(res, n = 800))DBI::dbClearResult(res)
# This is the failing call:DBI::dbGetQuery(con, "SELECT * FROM df_x LIMIT 1", immediate=TRUE)
#> Error: Failed to fetch row : ERROR: current transaction is aborted, commands ignored until end of transaction block# Also failing with:# DBI::dbGetQuery(con, "SELECT * FROM df_x LIMIT 1")# DBI::dbGetQuery(con, "SELECT * FROM df_x LIMIT 10", immediate = TRUE)# DBI::dbGetQuery(con, "SELECT * FROM df_x", immediate = TRUE)# Not reached in case of failureDBI::dbCommit(con)
@Antonov548: can you reproduce this with the most recent development (bleeding edge) version of Postgres and libpq? (Is there a Docker image that we can use? Otherwise, we'll need to build from source I'm afraid.)
Running with Postgres 15.2 and the dev version of RPostgres I still get the error.
Not sure which libpq version this is. Does this help?
otool -L /usr/local/opt/postgresql@15/lib/libpq.5.dylib
/usr/local/opt/postgresql@15/lib/libpq.5.dylib:
/usr/local/opt/postgresql@15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 13.0.0, current version 13.0.0)
/usr/local/opt/openssl@3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 2.0.0, current version 2.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
DBI::dbGetInfo(RPostgres::Postgres())
#> $driver.version#> [1] '1.4.6.9006'#> #> $client.version#> [1] '15.2'con<-DBI::dbConnect(RPostgres::Postgres())
write_table<-function(n) {
DBI::dbWriteTable(
con,
"df_x",
tibble::tibble(x=1:n),
temporary=TRUE,
overwrite=TRUE
)
}
DBI::dbBegin(con)
write_table(2e3)
res<-DBI::dbSendQuery(con, "SELECT * FROM df_x")
invisible(DBI::dbFetch(res, n=500))
DBI::dbClearResult(res)
# This is the failing call:DBI::dbGetQuery(con, "SELECT * FROM df_x LIMIT 1", immediate=TRUE)
#> Error: Failed to fetch row : ERROR: current transaction is aborted, commands ignored until end of transaction block
Activity
krlmlr commentedon Mar 9, 2023
Thanks, interesting. I can repro locally on Linux with Postgres 12 and
write_table(1e5).krlmlr commentedon Mar 16, 2023
Confirmed with Postgres 14 and 15 on macOS aarch64, built with client 14.5.
Reprex that uses simpler libpq calls under the hood, with variants:
Created on 2023-03-16 with reprex v2.0.2
@Antonov548: can you reproduce this with the most recent development (bleeding edge) version of Postgres and libpq? (Is there a Docker image that we can use? Otherwise, we'll need to build from source I'm afraid.)
mgirlich commentedon Mar 16, 2023
How curious that it is successful for
n = 800. A quick loop shows that:DBI::dbFetch(res, n = 590)Created on 2023-03-16 with reprex v2.0.2
krlmlr commentedon Apr 1, 2024
This no longer fails for me with libpq 14.11 run against Postgres 15. Are you still seeing this behavior?
mgirlich commentedon Apr 3, 2024
Running with Postgres 15.2 and the dev version of RPostgres I still get the error.
Not sure which libpq version this is. Does this help?
Created on 2024-04-03 with reprex v2.1.0
Session info
krlmlr commentedon Apr 13, 2024
This seems to be libpq 15.2 . I need to work on my setup (https://github.com/r-dbi/docker) to test with different libpq versions.