SQLiteSQLiteエラーコード
SQLITE_BUSY
busy
別表記: 5
どのような問題ですか?
コード SQLITE_BUSY · SQLiteが報告した問題です。
翻訳された説明
SQLITE_BUSY 結果コードは、他のデータベース接続 (通常は別のプロセスのデータベース接続) による同時アクティビティが原因で、データベース ファイルに書き込むことができなかった (場合によっては読み取れなかった) ことを示します。
たとえば、プロセス A が大規模な書き込みトランザクションの途中であり、同時にプロセス B が新しい書き込みトランザクションを開始しようとすると、SQLite は一度に 1 つのライターしかサポートしないため、プロセス B は SQLITE_BUSY 結果を返します。プロセス B は、新しいトランザクションを開始する前に、プロセス A がトランザクションを完了するまで待つ必要があります。 sqlite3_busy_timeout() および sqlite3_busy_handler() インターフェイスと、busy_timeout プラグマをプロセス B に使用すると、SQLITE_BUSY エラーの処理に役立ちます。
SQLITE_BUSY エラーは、トランザクションのどの時点でも発生する可能性があります。トランザクションの最初の開始時、書き込みまたは更新操作中、またはトランザクションのコミット時です。トランザクションの途中で SQLITE_BUSY エラーが発生するのを避けるために、アプリケーションは BEGIN だけではなく BEGIN IMMEDIATE を使用してトランザクションを開始できます。 BEGIN IMMEDIATE コマンド自体が SQLITE_BUSY を返す可能性がありますが、それが成功すると、SQLite は、次の COMMIT までの同じデータベースに対する後続の操作で SQLITE_BUSY が返されないことを保証します。
SQLITE_BUSY_RECOVERY および SQLITE_BUSY_SNAPSHOT も参照してください。
SQLITE_BUSY 結果コードは、SQLITE_BUSY が別のデータベース接続 (おそらく別のプロセス内) との競合を示すのに対し、SQLITE_LOCKED は同じデータベース接続 (場合によっては共有キャッシュを備えたデータベース接続) 内の競合を示すという点で SQLITE_LOCKED とは異なります。
Google Translate · 自動翻訳です。専門用語や適用条件は英語の原文で確認してください。
公式の説明 · 原文
The SQLITE_BUSY result code indicates that the database file could not be written (or in some cases read) because of concurrent activity by some other database connection, usually a database connection in a separate process.
For example, if process A is in the middle of a large write transaction and at the same time process B attempts to start a new write transaction, process B will get back an SQLITE_BUSY result because SQLite only supports one writer at a time. Process B will need to wait for process A to finish its transaction before starting a new transaction. The sqlite3_busy_timeout() and sqlite3_busy_handler() interfaces and the busy_timeout pragma are available to process B to help it deal with SQLITE_BUSY errors.
An SQLITE_BUSY error can occur at any point in a transaction: when the transaction is first started, during any write or update operations, or when the transaction commits. To avoid encountering SQLITE_BUSY errors in the middle of a transaction, the application can use BEGIN IMMEDIATE instead of just BEGIN to start a transaction. The BEGIN IMMEDIATE command might itself return SQLITE_BUSY, but if it succeeds, then SQLite guarantees that no subsequent operations on the same database through the next COMMIT will return SQLITE_BUSY.
See also: SQLITE_BUSY_RECOVERY and SQLITE_BUSY_SNAPSHOT.
The SQLITE_BUSY result code differs from SQLITE_LOCKED in that SQLITE_BUSY indicates a conflict with a separate database connection, probably in a separate process, whereas SQLITE_LOCKED indicates a conflict within the same database connection (or sometimes a database connection with a shared cache).
トラブルシューティング・診断リンク
まず、文書の製品・バージョン・発生環境が現在の状況と一致しているか確認してください。
- 一般的な診断ガイド
ロック待機時間とbusy handlerを確認 ↗
このコード専用 · 適用環境を確認
- コードリファレンス
結果コードの意味と処理に関する公式説明 ↗
定義・説明 · 解決手順ではありません
出典・利用条件
著作者: SQLite authors / Hwaci
ライセンス: Public domain dedication (SQLite code and documentation)
確認日: 2026-11-12
変更内容: English prose extracted; whitespace normalized; Korean context and classified official links added. Python code examples not redistributed. 翻訳された説明には、自動翻訳であることを表示しています。