database

package
v0.6.0-RC4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInmemoryWithHighConcurrency = errors.New("cannot use in-memory database with concurrency > 1")
	ErrDatabaseNotSupported        = errors.New("database not supported")
)

Functions

func AddPragmaToSQLite added in v0.4.0

func AddPragmaToSQLite(connString string) (string, error)

func CheckDeadlockLoggingEnabled

func CheckDeadlockLoggingEnabled(db *gorm.DB) (bool, error)

CheckDeadlockLoggingEnabled checks if innodb_print_all_deadlocks is enabled.

func DoRetry

func DoRetry(ctx context.Context, f func() error) error

func EnableDeadlockLogging

func EnableDeadlockLogging(db *gorm.DB) error

EnableDeadlockLogging enables logging of all deadlocks to the MySQL error log. By default, MySQL/MariaDB only logs the most recent deadlock. This setting persists until the server is restarted.

func GetDataLockWaits

func GetDataLockWaits(db *gorm.DB) ([]map[string]interface{}, error)

GetDataLockWaits returns current lock wait information from performance_schema. This requires MySQL 8.0.30+ or MariaDB 10.5+.

func GetLockWaitTransactions

func GetLockWaitTransactions(db *gorm.DB) ([]map[string]interface{}, error)

GetLockWaitTransactions returns transactions currently waiting for locks. This requires MySQL 8.0.30+ or MariaDB 10.5+.

func OpenFromCLI added in v0.2.28

func OpenFromCLI(c *cli.Context) (*gorm.DB, io.Closer, error)

func OpenWithLogger added in v0.3.0

func OpenWithLogger(connString string) (*gorm.DB, io.Closer, error)

func PrintDeadlockInfo

func PrintDeadlockInfo(db *gorm.DB) string

PrintDeadlockInfo prints detailed deadlock information from MySQL/MariaDB InnoDB status. This should be called when a deadlock error is detected to help diagnose the issue. Returns the deadlock information as a string, or empty string if not available.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL