mirror of
https://github.com/DeBrosOfficial/network.git
synced 2026-01-30 08:33:04 +00:00
some more fixes
This commit is contained in:
parent
1c2bde2d81
commit
5547c8ccb5
@ -232,6 +232,17 @@ func TestRQLite_ConcurrentInserts(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
table := GenerateTableName()
|
table := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup table after test
|
||||||
|
defer func() {
|
||||||
|
dropReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": table},
|
||||||
|
}
|
||||||
|
dropReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
schema := fmt.Sprintf(
|
schema := fmt.Sprintf(
|
||||||
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER)",
|
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER)",
|
||||||
table,
|
table,
|
||||||
@ -320,6 +331,17 @@ func TestRQLite_LargeBatchTransaction(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
table := GenerateTableName()
|
table := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup table after test
|
||||||
|
defer func() {
|
||||||
|
dropReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": table},
|
||||||
|
}
|
||||||
|
dropReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
schema := fmt.Sprintf(
|
schema := fmt.Sprintf(
|
||||||
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)",
|
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value TEXT)",
|
||||||
table,
|
table,
|
||||||
|
|||||||
@ -17,6 +17,17 @@ func TestRQLite_CreateTable(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
table := GenerateTableName()
|
table := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup table after test
|
||||||
|
defer func() {
|
||||||
|
dropReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": table},
|
||||||
|
}
|
||||||
|
dropReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
schema := fmt.Sprintf(
|
schema := fmt.Sprintf(
|
||||||
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP)",
|
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP)",
|
||||||
table,
|
table,
|
||||||
@ -47,6 +58,17 @@ func TestRQLite_InsertQuery(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
table := GenerateTableName()
|
table := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup table after test
|
||||||
|
defer func() {
|
||||||
|
dropReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": table},
|
||||||
|
}
|
||||||
|
dropReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
schema := fmt.Sprintf(
|
schema := fmt.Sprintf(
|
||||||
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)",
|
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)",
|
||||||
table,
|
table,
|
||||||
@ -245,6 +267,17 @@ func TestRQLite_LargeTransaction(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
table := GenerateTableName()
|
table := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup table after test
|
||||||
|
defer func() {
|
||||||
|
dropReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": table},
|
||||||
|
}
|
||||||
|
dropReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
schema := fmt.Sprintf(
|
schema := fmt.Sprintf(
|
||||||
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER)",
|
"CREATE TABLE IF NOT EXISTS %s (id INTEGER PRIMARY KEY AUTOINCREMENT, value INTEGER)",
|
||||||
table,
|
table,
|
||||||
@ -320,6 +353,23 @@ func TestRQLite_ForeignKeyMigration(t *testing.T) {
|
|||||||
orgsTable := GenerateTableName()
|
orgsTable := GenerateTableName()
|
||||||
usersTable := GenerateTableName()
|
usersTable := GenerateTableName()
|
||||||
|
|
||||||
|
// Cleanup tables after test
|
||||||
|
defer func() {
|
||||||
|
dropUsersReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": usersTable},
|
||||||
|
}
|
||||||
|
dropUsersReq.Do(context.Background())
|
||||||
|
|
||||||
|
dropOrgsReq := &HTTPRequest{
|
||||||
|
Method: http.MethodPost,
|
||||||
|
URL: GetGatewayURL() + "/v1/rqlite/drop-table",
|
||||||
|
Body: map[string]interface{}{"table": orgsTable},
|
||||||
|
}
|
||||||
|
dropOrgsReq.Do(context.Background())
|
||||||
|
}()
|
||||||
|
|
||||||
// Create base tables
|
// Create base tables
|
||||||
createOrgsReq := &HTTPRequest{
|
createOrgsReq := &HTTPRequest{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
|
|||||||
@ -23,10 +23,11 @@ func NewRQLiteAdapter(manager *RQLiteManager) (*RQLiteAdapter, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configure connection pool with proper timeouts and limits
|
// Configure connection pool with proper timeouts and limits
|
||||||
db.SetMaxOpenConns(25) // Maximum number of open connections
|
// Optimized for concurrent operations and fast bad connection eviction
|
||||||
db.SetMaxIdleConns(5) // Maximum number of idle connections
|
db.SetMaxOpenConns(100) // Allow more concurrent connections to prevent queuing
|
||||||
db.SetConnMaxLifetime(5 * time.Minute) // Maximum lifetime of a connection
|
db.SetMaxIdleConns(10) // Keep fewer idle connections to force fresh reconnects
|
||||||
db.SetConnMaxIdleTime(2 * time.Minute) // Maximum idle time before closing
|
db.SetConnMaxLifetime(30 * time.Second) // Short lifetime ensures bad connections die quickly
|
||||||
|
db.SetConnMaxIdleTime(10 * time.Second) // Kill idle connections quickly to prevent stale state
|
||||||
|
|
||||||
return &RQLiteAdapter{
|
return &RQLiteAdapter{
|
||||||
manager: manager,
|
manager: manager,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user