Fix transaction cleanup

This commit is contained in:
jaina heartles 2022-12-10 01:41:26 -08:00
parent c6af6caec7
commit eae70d9b9c

View file

@ -420,7 +420,7 @@ fn Tx(comptime tx_level: u8) type {
if (tx_level != 0) @compileError("close must be called on root db"); if (tx_level != 0) @compileError("close must be called on root db");
if (self.conn.current_tx_level != 0) { if (self.conn.current_tx_level != 0) {
std.log.warn("Database released while transaction in progress!", .{}); std.log.warn("Database released while transaction in progress!", .{});
self.rollbackUnchecked() catch {}; self.rollbackUnchecked() catch {}; // TODO: Burn database connection
} }
if (!self.conn.in_use.swap(false, .AcqRel)) @panic("Double close on db conection"); if (!self.conn.in_use.swap(false, .AcqRel)) @panic("Double close on db conection");
@ -719,6 +719,7 @@ fn Tx(comptime tx_level: u8) type {
fn rollbackUnchecked(self: Self) !void { fn rollbackUnchecked(self: Self) !void {
try self.execInternal("ROLLBACK", {}, .{}, false); try self.execInternal("ROLLBACK", {}, .{}, false);
self.conn.current_tx_level = 0;
} }
}; };
} }