mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
style(database): fix gofmt comment indentation in concurrent_test.go
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
545f5a3672
commit
de4d40a25c
1 changed files with 11 additions and 8 deletions
|
|
@ -24,9 +24,10 @@ import (
|
||||||
// occur at all.
|
// occur at all.
|
||||||
//
|
//
|
||||||
// Chain of proof:
|
// Chain of proof:
|
||||||
// TestConcurrentWrites/with_fix_* proves SetMaxOpenConns(1) fixes the bug.
|
//
|
||||||
// TestInitDBConcurrencyConfig/single_connection_pool proves InitDB calls it.
|
// TestConcurrentWrites/with_fix_* proves SetMaxOpenConns(1) fixes the bug.
|
||||||
// Therefore InitDB fixes the bug.
|
// TestInitDBConcurrencyConfig/single_connection_pool proves InitDB calls it.
|
||||||
|
// Therefore InitDB fixes the bug.
|
||||||
func TestInitDBConcurrencyConfig(t *testing.T) {
|
func TestInitDBConcurrencyConfig(t *testing.T) {
|
||||||
dbPath := filepath.Join(t.TempDir(), "test.db")
|
dbPath := filepath.Join(t.TempDir(), "test.db")
|
||||||
if err := InitDB(dbPath); err != nil {
|
if err := InitDB(dbPath); err != nil {
|
||||||
|
|
@ -63,13 +64,15 @@ func TestInitDBConcurrencyConfig(t *testing.T) {
|
||||||
// The ONLY variable that differs between the two sub-tests is MaxOpenConns.
|
// The ONLY variable that differs between the two sub-tests is MaxOpenConns.
|
||||||
//
|
//
|
||||||
// Without fix (MaxOpenConns=2):
|
// Without fix (MaxOpenConns=2):
|
||||||
// conn1 acquires the SQLite write lock; conn2 is a separate connection that
|
//
|
||||||
// immediately tries to write and fails because it cannot wait out the lock.
|
// conn1 acquires the SQLite write lock; conn2 is a separate connection that
|
||||||
|
// immediately tries to write and fails because it cannot wait out the lock.
|
||||||
//
|
//
|
||||||
// With fix (MaxOpenConns=1):
|
// With fix (MaxOpenConns=1):
|
||||||
// conn2 cannot be acquired from the pool while conn1 is in use, so it
|
//
|
||||||
// blocks at the Go pool level instead of racing at the SQLite level.
|
// conn2 cannot be acquired from the pool while conn1 is in use, so it
|
||||||
// Once conn1 is released, conn2 gets the connection and writes without error.
|
// blocks at the Go pool level instead of racing at the SQLite level.
|
||||||
|
// Once conn1 is released, conn2 gets the connection and writes without error.
|
||||||
func TestConcurrentWrites(t *testing.T) {
|
func TestConcurrentWrites(t *testing.T) {
|
||||||
const busyTimeout = 10 // ms — short so lock contention fails fast
|
const busyTimeout = 10 // ms — short so lock contention fails fast
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue