mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-08 22:12:29 +08:00
Compare commits
5 Commits
fix/ob-ora
...
fix/ob-ora
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ee8698165 | ||
|
|
9ae35e5fec | ||
|
|
b618927454 | ||
|
|
e8ad34d2f0 | ||
|
|
007fdc9a5d |
@@ -37,6 +37,13 @@ describe('formatSqlExecutionError', () => {
|
|||||||
expect(formatted).toContain('Raw error: driver returned unexpected status 123');
|
expect(formatted).toContain('Raw error: driver returned unexpected status 123');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('recognizes driver bad connection during SQL execution as timeout semantics', () => {
|
||||||
|
const formatted = formatSqlExecutionError('第 1 条语句执行失败:driver: bad connection');
|
||||||
|
|
||||||
|
expect(formatted).toContain('Semantic meaning: Query timed out or was canceled');
|
||||||
|
expect(formatted).toContain('Raw error: 第 1 条语句执行失败:driver: bad connection');
|
||||||
|
});
|
||||||
|
|
||||||
it('recognizes localized connection-timeout wrappers as timeout semantics', () => {
|
it('recognizes localized connection-timeout wrappers as timeout semantics', () => {
|
||||||
const translate = (key: string, params?: Record<string, unknown>) => {
|
const translate = (key: string, params?: Record<string, unknown>) => {
|
||||||
if (key === 'query_editor.sql_error.wrapper.semantic_line') {
|
if (key === 'query_editor.sql_error.wrapper.semantic_line') {
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ const SQL_ERROR_RULES: SqlErrorSemanticRule[] = [
|
|||||||
/context cancelled/i,
|
/context cancelled/i,
|
||||||
/timeout/i,
|
/timeout/i,
|
||||||
/timed out/i,
|
/timed out/i,
|
||||||
|
/driver:\s*bad connection/i,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import (
|
|||||||
"GoNavi-Wails/internal/db"
|
"GoNavi-Wails/internal/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultOceanBaseOracleQueryTimeoutSeconds = 120
|
||||||
|
|
||||||
func normalizeRunConfig(config connection.ConnectionConfig, dbName string) connection.ConnectionConfig {
|
func normalizeRunConfig(config connection.ConnectionConfig, dbName string) connection.ConnectionConfig {
|
||||||
runConfig := config
|
runConfig := config
|
||||||
name := strings.TrimSpace(dbName)
|
name := strings.TrimSpace(dbName)
|
||||||
@@ -54,6 +56,10 @@ func applyOceanBaseOracleCurrentSchemaInit(config connection.ConnectionConfig, s
|
|||||||
if normalizedSchema == "" {
|
if normalizedSchema == "" {
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
if config.Timeout <= 0 {
|
||||||
|
// OceanBase Oracle 查询经常需要经过 OBProxy/Oracle driver 的读等待;默认 30s 容易把慢查询误报成 driver: bad connection。
|
||||||
|
config.Timeout = defaultOceanBaseOracleQueryTimeoutSeconds
|
||||||
|
}
|
||||||
values, err := url.ParseQuery(strings.TrimSpace(config.ConnectionParams))
|
values, err := url.ParseQuery(strings.TrimSpace(config.ConnectionParams))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config
|
return config
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ func TestNormalizeRunConfig_OceanBaseOracleAddsCurrentSchemaInit(t *testing.T) {
|
|||||||
if runConfig.Database != "OBORCL" {
|
if runConfig.Database != "OBORCL" {
|
||||||
t.Fatalf("expected OceanBase Oracle service name to stay OBORCL, got %q", runConfig.Database)
|
t.Fatalf("expected OceanBase Oracle service name to stay OBORCL, got %q", runConfig.Database)
|
||||||
}
|
}
|
||||||
|
if runConfig.Timeout != defaultOceanBaseOracleQueryTimeoutSeconds {
|
||||||
|
t.Fatalf("expected OceanBase Oracle default query timeout %d, got %d", defaultOceanBaseOracleQueryTimeoutSeconds, runConfig.Timeout)
|
||||||
|
}
|
||||||
values, err := url.ParseQuery(runConfig.ConnectionParams)
|
values, err := url.ParseQuery(runConfig.ConnectionParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected connection params parse error: %v", err)
|
t.Fatalf("unexpected connection params parse error: %v", err)
|
||||||
@@ -30,17 +33,21 @@ func TestNormalizeRunConfig_OceanBaseOracleAddsCurrentSchemaInit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNormalizeRunConfig_OceanBaseOraclePreservesExistingInit(t *testing.T) {
|
func TestNormalizeRunConfig_OceanBaseOraclePreservesExplicitTimeoutAndExistingInit(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
config := connection.ConnectionConfig{
|
config := connection.ConnectionConfig{
|
||||||
Type: "oceanbase",
|
Type: "oceanbase",
|
||||||
Database: "OBORCL",
|
Database: "OBORCL",
|
||||||
OceanBaseProtocol: "oracle",
|
OceanBaseProtocol: "oracle",
|
||||||
|
Timeout: 45,
|
||||||
ConnectionParams: "init=ALTER+SESSION+SET+NLS_DATE_FORMAT%3D%27YYYY-MM-DD%27&timeout=10s",
|
ConnectionParams: "init=ALTER+SESSION+SET+NLS_DATE_FORMAT%3D%27YYYY-MM-DD%27&timeout=10s",
|
||||||
}
|
}
|
||||||
runConfig := normalizeRunConfig(config, "sbdev")
|
runConfig := normalizeRunConfig(config, "sbdev")
|
||||||
|
|
||||||
|
if runConfig.Timeout != 45 {
|
||||||
|
t.Fatalf("expected explicit timeout to be preserved, got %d", runConfig.Timeout)
|
||||||
|
}
|
||||||
values, err := url.ParseQuery(runConfig.ConnectionParams)
|
values, err := url.ParseQuery(runConfig.ConnectionParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected connection params parse error: %v", err)
|
t.Fatalf("unexpected connection params parse error: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user