forked from localytics/odbc_adapter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request localytics#32 from localytics/mshearer_expired_token
Handle connection failure by trying to reconnect and translating the error to ConnectionFailedError so the caller knows to retry
- Loading branch information
Showing
5 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,11 @@ FROM ruby:2.4.0 | |
MAINTAINER [email protected] | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN echo "deb http://deb.debian.org/debian/ jessie main" > /etc/apt/sources.list | ||
RUN echo "deb-src http://deb.debian.org/debian/ jessie main" >> /etc/apt/sources.list | ||
RUN echo "deb http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list | ||
RUN echo "deb-src http://security.debian.org/ jessie/updates main" >> /etc/apt/sources.list | ||
RUN apt-get update && apt-get -y install libnss3-tools unixodbc-dev libmyodbc mysql-client odbc-postgresql postgresql | ||
|
||
WORKDIR /workspace | ||
CMD docker/docker-entrypoint.sh | ||
CMD docker/docker-entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
module ODBCAdapter | ||
class QueryTimeoutError < ActiveRecord::StatementInvalid | ||
end | ||
class ConnectionFailedError < ActiveRecord::StatementInvalid | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ODBCAdapter | ||
VERSION = '5.0.4'.freeze | ||
VERSION = '5.0.5'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'test_helper' | ||
|
||
class ConnectionFailTest < Minitest::Test | ||
def test_connection_fail | ||
# We're only interested in testing a MySQL connection failure for now. | ||
# Postgres disconnects generate a different class of errors | ||
skip 'Only executed for MySQL' unless ActiveRecord::Base.connection.instance_values['config'][:conn_str].include? 'MySQL' | ||
begin | ||
conn.execute('KILL CONNECTION_ID();') | ||
rescue => e | ||
puts "caught exception #{e}" | ||
end | ||
assert_raises(ODBCAdapter::ConnectionFailedError) { User.average(:letters).round(2) } | ||
end | ||
|
||
def conn | ||
ActiveRecord::Base.connection | ||
end | ||
end |