---
title: "Something you probably want to know about if you're using SQLite in Golang"
description: "In SQLite's WAL mode, an unclosed Go database/sql rows object keeps a read transaction open, which stops checkpoints from moving changes from the WAL file into the main database file."
url: "https://swe.quest/articles/something-you-probably-want-to-know-about-if-you-re-using-sqlite-in-golang-998bba3901e282c7"
canonical: "https://turso.tech/blog/something-you-probably-want-to-know-about-if-youre-using-sqlite-in-golang-72547ad625f1"
source: "Turso"
published: "2023-08-03"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 5
tags: ["sqlite","go","storage-engines","debugging"]
---

# Something you probably want to know about if you're using SQLite in Golang

A post on [Turso](https://swe.quest/sources/turso.md), published 2023-08-03, 5 min read, Deep dive. Original: [https://turso.tech/blog/something-you-probably-want-to-know-about-if-youre-using-sqlite-in-golang-72547ad625f1](https://turso.tech/blog/something-you-probably-want-to-know-about-if-youre-using-sqlite-in-golang-72547ad625f1)

## Summary

In SQLite's WAL mode, an unclosed Go database/sql rows object keeps a read transaction open, which stops checkpoints from moving changes from the WAL file into the main database file. The WAL then grows without bound until the process restarts. In the example, leaking rows left a 42 MB WAL and a 4.1 kB main file, versus about 406 kB and 4.1 MB normally, and a manual PRAGMA wal\_checkpoint did not fix it. Always close the results of Query and QueryContext; the same leak also blocks VACUUM.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [SQLite](https://swe.quest/tags/sqlite.md) (Data & databases)
- [Go](https://swe.quest/tags/go.md) (Languages)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- Go database/sql ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- SQLite basics ([easy posts on SQLite](https://swe.quest/tags/sqlite.md?difficulty=easy))

## Keywords

SQLite, WAL, database/sql, checkpoint, VACUUM, libSQL

## Related posts

- [A linter I really recommend you to use if you're doing SQL in Golang](https://swe.quest/articles/a-linter-i-really-recommend-you-to-use-if-you-re-doing-sql-in-golang-01ce20ff247e64a5.md): Turso · 2023-08-10 · Medium · 3 min read · Go, Static analysis, CI/CD, SQL
  The sqlclosecheck linter catches unclosed sql.Rows and sql.Stmt objects in Go code, which otherwise can cause deadlocks or inefficient disk use in databases like SQLite.
- [How to get your database access code deadlocked in Golang](https://swe.quest/articles/how-to-get-your-database-access-code-deadlocked-in-golang-f01f82ad269b4372.md): Turso · 2023-07-27 · Medium · 5 min read · Go, Concurrency, Debugging, Databases
  In Go's database/sql, failing to close a Rows result can deadlock the program when a loop over query results returns early on error.
- [An adventure in writing compatible systems](https://swe.quest/articles/an-adventure-in-writing-compatible-systems-f48d37f87fc6e365.md): Turso · 2025-08-28 · Medium · 4 min read · SQLite, Storage engines, Formal methods, Debugging, Rust
  Turso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact.
- [Birth and death of a row in Turso's MVCC](https://swe.quest/articles/birth-and-death-of-a-row-in-turso-s-mvcc-f60b68028888940e.md): Turso · 2026-10-19 · Hard · 14 min read · Storage engines, SQLite, Consistency models, Databases
  Turso's MVCC, modeled on Hekaton, tracks each row as a chain of versions in a lock-free SkipMap, with begin/end fields holding a TxId while a transaction is active and a commit timestamp once it commits.
- [Turso v0.4.0](https://swe.quest/articles/turso-v0-4-0-191cca637e457c1d.md): Turso · 2026-01-05 · Medium · 3 min read · SQLite, Storage engines, Query engines, Local-first & sync, Concurrency
  Turso v0.4.0 overhauls its experimental MVCC mode, which lifts SQLite's single-writer limit, adding index support, checkpointing and recovery.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
