diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-06-28 10:34:00 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-06-28 07:34:00 -0700 |
commit | 005dd0754ba6dec00d8e4a84a297d0f35fbefb2b (patch) | |
tree | 9a21ff859d987cb067371939f37e385d97f92e03 | |
parent | 2dea567dcfcdfcd016c0da55a120c6e854760fb0 (diff) | |
download | chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.tar.gz chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.tar.bz2 chat-005dd0754ba6dec00d8e4a84a297d0f35fbefb2b.zip |
Update gorp to support query timeouts on postgres (#6730)
* Update gorp to support query timeouts on postgres
* Update help text to remove postgres exception
* Fix glide.lock
-rw-r--r-- | glide.lock | 6 | ||||
-rw-r--r-- | glide.yaml | 2 | ||||
-rw-r--r-- | vendor/github.com/mattermost/gorp/.gitignore | 1 | ||||
-rw-r--r-- | vendor/github.com/mattermost/gorp/gorp.go | 21 | ||||
-rw-r--r-- | vendor/github.com/mattermost/gorp/select.go | 23 | ||||
-rw-r--r-- | webapp/components/admin_console/database_settings.jsx | 2 | ||||
-rwxr-xr-x | webapp/i18n/en.json | 2 |
7 files changed, 19 insertions, 38 deletions
diff --git a/glide.lock b/glide.lock index 7b75dbd69..984f3dd9a 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 8abe00d58923fa7855f666aac2a2ee1636aad6734c05e3b9895a084ff0f1b56c -updated: 2017-06-20T15:53:07.620238453-07:00 +hash: 4c29ee4e38944411744a2a1af3e71836591d28feea24b328ab3d440a9ad1cef0 +updated: 2017-06-23T08:58:13.944294825-04:00 imports: - name: github.com/alecthomas/log4go version: 3fbce08846379ec7f4f6bc7fce6dd01ce28fae4c @@ -83,7 +83,7 @@ imports: - name: github.com/magiconair/properties version: 51463bfca2576e06c62a8504b5c0f06d61312647 - name: github.com/mattermost/gorp - version: cab337059e349c91a4b917c9be50708813619543 + version: 995ddf2264c4ad45fbaf342f7500e4787ebae84a - name: github.com/mattermost/rsc version: bbaefb05eaa0389ea712340066837c8ce4d287f9 subpackages: diff --git a/glide.yaml b/glide.yaml index 63647b0c9..3f617c997 100644 --- a/glide.yaml +++ b/glide.yaml @@ -82,4 +82,4 @@ import: - package: gopkg.in/olivere/elastic.v5 version: v5.0.41 - package: github.com/mattermost/gorp - version: cab337059e349c91a4b917c9be50708813619543
\ No newline at end of file + version: 995ddf2264c4ad45fbaf342f7500e4787ebae84a diff --git a/vendor/github.com/mattermost/gorp/.gitignore b/vendor/github.com/mattermost/gorp/.gitignore index d18c8ca70..c1bbd21d1 100644 --- a/vendor/github.com/mattermost/gorp/.gitignore +++ b/vendor/github.com/mattermost/gorp/.gitignore @@ -7,3 +7,4 @@ _obj 6.out gorptest.bin tmp +*.swp diff --git a/vendor/github.com/mattermost/gorp/gorp.go b/vendor/github.com/mattermost/gorp/gorp.go index 728971e48..784712fd9 100644 --- a/vendor/github.com/mattermost/gorp/gorp.go +++ b/vendor/github.com/mattermost/gorp/gorp.go @@ -173,13 +173,9 @@ func exec(e SqlExecutor, query string, doTimeout bool, args ...interface{}) (sql query, args = maybeExpandNamedQuery(dbMap, query, args) } - if doTimeout && dbMap.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) - defer cancel() - return executor.ExecContext(ctx, query, args...) - } else { - return executor.Exec(query, args...) - } + ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) + defer cancel() + return executor.ExecContext(ctx, query, args...) } // maybeExpandNamedQuery checks the given arg to see if it's eligible to be used @@ -410,14 +406,9 @@ func get(m *DbMap, exec SqlExecutor, i interface{}, dest[x] = target } - var row *sql.Row - if m.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) - defer cancel() - row = exec.QueryRowContext(ctx, plan.query, keys...) - } else { - row = exec.QueryRow(plan.query, keys...) - } + ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) + defer cancel() + row := exec.QueryRowContext(ctx, plan.query, keys...) err = row.Scan(dest...) if err != nil { diff --git a/vendor/github.com/mattermost/gorp/select.go b/vendor/github.com/mattermost/gorp/select.go index 1967b0246..10c84b084 100644 --- a/vendor/github.com/mattermost/gorp/select.go +++ b/vendor/github.com/mattermost/gorp/select.go @@ -167,15 +167,9 @@ func selectVal(e SqlExecutor, holder interface{}, query string, args ...interfac query, args = maybeExpandNamedQuery(dbMap, query, args) } - var rows *sql.Rows - var err error - if dbMap.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) - defer cancel() - rows, err = e.QueryContext(ctx, query, args...) - } else { - rows, err = e.Query(query, args...) - } + ctx, cancel := context.WithTimeout(context.Background(), dbMap.QueryTimeout) + defer cancel() + rows, err := e.QueryContext(ctx, query, args...) if err != nil { return err @@ -267,14 +261,9 @@ func rawselect(m *DbMap, exec SqlExecutor, i interface{}, query string, } // Run the query - var rows *sql.Rows - if m.Dialect.Name() != "PostgresDialect" { - ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) - defer cancel() - rows, err = exec.QueryContext(ctx, query, args...) - } else { - rows, err = exec.Query(query, args...) - } + ctx, cancel := context.WithTimeout(context.Background(), m.QueryTimeout) + defer cancel() + rows, err := exec.QueryContext(ctx, query, args...) if err != nil { return nil, err diff --git a/webapp/components/admin_console/database_settings.jsx b/webapp/components/admin_console/database_settings.jsx index 7b8891b2a..e182db70e 100644 --- a/webapp/components/admin_console/database_settings.jsx +++ b/webapp/components/admin_console/database_settings.jsx @@ -142,7 +142,7 @@ export default class DatabaseSettings extends AdminSettings { helpText={ <FormattedMessage id='admin.sql.queryTimeoutDescription' - defaultMessage='The number of seconds to wait for a response from the database after opening a connection and sending the query. Errors that you see in the UI or in the logs as a result of a query timeout can vary depending on the type of query. This setting has no effect on PostgreSQL databases.' + defaultMessage='The number of seconds to wait for a response from the database after opening a connection and sending the query. Errors that you see in the UI or in the logs as a result of a query timeout can vary depending on the type of query.' /> } value={this.state.queryTimeout} diff --git a/webapp/i18n/en.json b/webapp/i18n/en.json index 419486b9d..b1f688e40 100755 --- a/webapp/i18n/en.json +++ b/webapp/i18n/en.json @@ -832,7 +832,7 @@ "admin.sql.maxOpenTitle": "Maximum Open Connections:", "admin.sql.noteDescription": "Changing properties in this section will require a server restart before taking effect.", "admin.sql.noteTitle": "Note:", - "admin.sql.queryTimeoutDescription": "The number of seconds to wait for a response from the database after opening a connection and sending the query. Errors that you see in the UI or in the logs as a result of a query timeout can vary depending on the type of query. This setting has no effect on PostgreSQL databases.", + "admin.sql.queryTimeoutDescription": "The number of seconds to wait for a response from the database after opening a connection and sending the query. Errors that you see in the UI or in the logs as a result of a query timeout can vary depending on the type of query.", "admin.sql.queryTimeoutExample": "E.g.: \"30\"", "admin.sql.queryTimeoutTitle": "Query Timeout:", "admin.sql.replicas": "Data Source Replicas:", |