Skip to content

fix transactions with database.DB type

Created by: camdencheek

This fixes an issue that caused long-running transactions in production. The problem was that, when creating a transaction, we make interface assertions against the concrete type of dbutil.DB, which work fine when dbutil.DB is always a *sql.DB or *sql.Tx. However, with the new database.DB type, it embeds a dbutil.DB, so the transaction methods aren't exposed, making these interface assertions fail.

This commit adds an Unwrap() dbutil.DB method to database.DB so that, when determining what the underlying type is for transactions, we can unwrap a database.DB to expose those methods.

This is not ideal, and I have some ideas for making it better, but they require being further along in the refactoring process to be viable. For now, I think this is a reasonable band-aid that allows the process to continue.

Also, I added a few tests to make sure this behavior doesn't regress, and that will catch issues like the one from this morning.

Addresses the issue that caused to revert in #26946

Merge request reports

Loading