Skip to content

Commit a490fb4

Browse files
authored
fix(oracle): disabling global hidden internal timeout (#298)
* fix: try query command without reading rows * fix: try setting maxLifeTime parameter * fix: try setting maxIdleTime parameter * fix: keep options on oracle-raw urls * fix(oracle): disabling global hidden internal timeout * test(oracle): fix failing test
1 parent 34eb10a commit a490fb4

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Types of changes
1414
- `Fixed` for any bug fixes.
1515
- `Security` in case of vulnerabilities.
1616

17+
## [3.0.1]
18+
19+
- `Fixed` hidden global internal timeout of 240s with Oracle driver is now disabled by default
20+
1721
## [3.0.0]
1822

1923
- `Changed` table or column names were not correctly matched in terms of case sensitivity (lowercase or uppercase) in table.yaml

internal/app/urlbuilder/urlbuilder.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,35 @@ func GenOracleRaw(u *dburl.URL) (string, string, error) {
6666

6767
func genJDBCOracle(u *dburl.URL) (string, string, error) {
6868
if u.User == nil {
69-
return go_ora.BuildJDBC("", "", u.Host, map[string]string{}), "", nil
69+
return go_ora.BuildJDBC("", "", u.Host, getOptions(u)), "", nil
7070
}
7171

7272
if un := u.User.Username(); len(un) > 0 {
7373
if up, ok := u.User.Password(); ok {
74-
return go_ora.BuildJDBC(u.User.Username(), up, u.Host, map[string]string{}), "", nil
74+
return go_ora.BuildJDBC(u.User.Username(), up, u.Host, getOptions(u)), "", nil
7575
} else {
76-
return go_ora.BuildJDBC(u.User.Username(), "", u.Host, map[string]string{}), "", nil
76+
return go_ora.BuildJDBC(u.User.Username(), "", u.Host, getOptions(u)), "", nil
7777
}
7878
}
7979

80-
return go_ora.BuildJDBC("", "", u.Host, map[string]string{}), "", nil
80+
return go_ora.BuildJDBC("", "", u.Host, getOptions(u)), "", nil
81+
}
82+
83+
func getOptions(u *dburl.URL) map[string]string {
84+
values := u.Query()
85+
86+
options := make(map[string]string, len(values))
87+
88+
// fix: we want the global timeout to be disabled, like it is for every other drivers
89+
options["TIMEOUT"] = "0"
90+
91+
for key, vals := range values {
92+
if len(vals) > 0 {
93+
options[key] = vals[len(vals)-1]
94+
}
95+
}
96+
97+
return options
8198
}
8299

83100
func init() {

internal/app/urlbuilder/urlbuilder_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package urlbuilder
22

33
import (
4+
"strings"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
@@ -31,7 +32,7 @@ func TestBuildOracleURL(t *testing.T) {
3132
t.Errorf("parse return error : %v", err)
3233
}
3334

34-
assert.Equal(t, tt.want, url.DSN)
35+
assert.Equal(t, tt.want, strings.ReplaceAll(strings.ReplaceAll(url.DSN, "TIMEOUT=0&", ""), "&TIMEOUT=0", ""))
3536
})
3637
}
3738
}

0 commit comments

Comments
 (0)