master_slave_adapter 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +19 -14
- data/lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb +2 -2
- data/lib/active_record/connection_adapters/master_slave_adapter/version.rb +1 -1
- data/lib/active_record/connection_adapters/mysql2_master_slave_adapter.rb +0 -4
- data/lib/active_record/connection_adapters/mysql_master_slave_adapter.rb +0 -13
- data/spec/common/support/mysql_consistency_examples.rb +1 -11
- data/spec/integration/support/mysql_setup_helper.rb +12 -11
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,30 @@
|
|
1
|
+
# 1.1.1 (November 17, 2012)
|
2
|
+
|
3
|
+
* [BUGFIX] Fix activerecord 3.2 compatibility
|
4
|
+
* Fix setup of mysql integration servers
|
5
|
+
|
1
6
|
# 1.1.0 (November 15, 2012)
|
2
7
|
|
3
|
-
* [BUGFIX] Don't raise MasterUnavailable if a slave is unavailable
|
8
|
+
* [BUGFIX] Don't raise MasterUnavailable if a slave is unavailable
|
4
9
|
|
5
10
|
# 1.0.0 (July 24, 2012)
|
6
11
|
|
7
|
-
* Add support for unavailable master connection
|
8
|
-
* Restrict the public interface. Removed the following methods:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
* Fix 1.8.7 compliance
|
15
|
-
* Fix bug which led to infinitely connection stack growth
|
16
|
-
* Add ActiveRecord 3.x compatibility
|
17
|
-
* Add support for Mysql2
|
12
|
+
* Add support for unavailable master connection
|
13
|
+
* Restrict the public interface. Removed the following methods:
|
14
|
+
* all class methods from ActiveRecord::ConnectionAdapters::MasterSlaveAdapter
|
15
|
+
* #current_connection=
|
16
|
+
* #current_clock=
|
17
|
+
* #slave_consistent?
|
18
|
+
* ActiveRecord::Base.on_commit and ActiveRecord::Base.on_rollback
|
19
|
+
* Fix 1.8.7 compliance
|
20
|
+
* Fix bug which led to infinitely connection stack growth
|
21
|
+
* Add ActiveRecord 3.x compatibility
|
22
|
+
* Add support for Mysql2
|
18
23
|
|
19
24
|
# 0.2.0 (April 2, 2012)
|
20
25
|
|
21
|
-
* Add support for ActiveRecord's query cache
|
26
|
+
* Add support for ActiveRecord's query cache
|
22
27
|
|
23
28
|
# 0.1.10 (March 06, 2012)
|
24
29
|
|
25
|
-
* Delegate #visitor to master connection
|
30
|
+
* Delegate #visitor to master connection
|
data/lib/active_record/connection_adapters/master_slave_adapter/shared_mysql_adapter_behavior.rb
CHANGED
@@ -17,7 +17,7 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
def master_clock
|
19
19
|
conn = master_connection
|
20
|
-
if status = conn.uncached {
|
20
|
+
if status = conn.uncached { conn.select_one("SHOW MASTER STATUS") }
|
21
21
|
Clock.new(status['File'], status['Position'])
|
22
22
|
else
|
23
23
|
Clock.infinity
|
@@ -29,7 +29,7 @@ module ActiveRecord
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def slave_clock(conn)
|
32
|
-
if status = conn.uncached {
|
32
|
+
if status = conn.uncached { conn.select_one("SHOW SLAVE STATUS") }
|
33
33
|
Clock.new(status['Relay_Master_Log_File'], status['Exec_Master_Log_Pos'])
|
34
34
|
else
|
35
35
|
Clock.zero
|
@@ -17,19 +17,6 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
if MysqlAdapter.instance_methods.map(&:to_sym).include?(:exec_without_stmt)
|
21
|
-
# The MysqlAdapter in ActiveRecord > v3.1 uses prepared statements which
|
22
|
-
# don't return any results for queries like "SHOW MASTER/SLAVE STATUS",
|
23
|
-
# so we have to use normal queries here.
|
24
|
-
def select_hash(conn, sql)
|
25
|
-
conn.exec_without_stmt(sql).first
|
26
|
-
end
|
27
|
-
else
|
28
|
-
def select_hash(conn, sql)
|
29
|
-
conn.select_one(sql)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
20
|
CONNECTION_ERRORS = [
|
34
21
|
Mysql::Error::CR_CONNECTION_ERROR, # query: not connected
|
35
22
|
Mysql::Error::CR_CONN_HOST_ERROR, # Can't connect to MySQL server on '%s' (%d)
|
@@ -11,22 +11,12 @@ shared_examples_for 'mysql consistency' do
|
|
11
11
|
Clock.new('', pos)
|
12
12
|
end
|
13
13
|
|
14
|
-
def supports_prepared_statements?
|
15
|
-
described_class == ActiveRecord::ConnectionAdapters::MysqlMasterSlaveAdapter &&
|
16
|
-
ActiveRecord::ConnectionAdapters::MysqlAdapter.instance_methods.map(&:to_sym).include?(:exec_without_stmt)
|
17
|
-
end
|
18
|
-
|
19
|
-
def select_method
|
20
|
-
supports_prepared_statements? ? :exec_without_stmt : :select_one
|
21
|
-
end
|
22
|
-
|
23
14
|
def should_report_clock(pos, connection, log_file, log_pos, sql)
|
24
15
|
pos = Array(pos)
|
25
16
|
values = pos.map { |p| { log_file => '', log_pos => p } }
|
26
|
-
values.map! { |result| [ result ] } if supports_prepared_statements?
|
27
17
|
|
28
18
|
connection.
|
29
|
-
should_receive(
|
19
|
+
should_receive(:select_one).exactly(pos.length).times.
|
30
20
|
with(sql).
|
31
21
|
and_return(*values)
|
32
22
|
end
|
@@ -73,14 +73,13 @@ module MysqlSetupHelper
|
|
73
73
|
[:master, :slave].each do |name|
|
74
74
|
path = location(name)
|
75
75
|
config_path = File.join(path, "my.cnf")
|
76
|
-
data_path = File.join(path, "data")
|
77
76
|
base_dir = File.dirname(File.dirname(`which mysql_install_db`))
|
78
77
|
|
79
78
|
FileUtils.rm_rf(path)
|
80
79
|
FileUtils.mkdir_p(path)
|
81
80
|
File.open(config_path, "w") { |file| file << config(name) }
|
82
81
|
|
83
|
-
`mysql_install_db --
|
82
|
+
`mysql_install_db --defaults-file='#{config_path}' --basedir='#{base_dir}' --user=''`
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
@@ -160,15 +159,17 @@ private
|
|
160
159
|
|
161
160
|
<<-EOS
|
162
161
|
[mysqld]
|
163
|
-
pid-file
|
164
|
-
socket
|
165
|
-
port
|
166
|
-
log-error
|
167
|
-
datadir
|
168
|
-
log-bin
|
169
|
-
log-bin-index
|
170
|
-
server-id
|
171
|
-
lower_case_table_names
|
162
|
+
pid-file = #{path}/mysqld.pid
|
163
|
+
socket = #{path}/mysqld.sock
|
164
|
+
port = #{port(name)}
|
165
|
+
log-error = #{path}/error.log
|
166
|
+
datadir = #{path}/data
|
167
|
+
log-bin = #{name}-bin
|
168
|
+
log-bin-index = #{name}-bin.index
|
169
|
+
server-id = #{server_id(name)}
|
170
|
+
lower_case_table_names = 1
|
171
|
+
sql-mode = ''
|
172
|
+
replicate-ignore-db = mysql
|
172
173
|
EOS
|
173
174
|
end
|
174
175
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: master_slave_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2012-11-
|
18
|
+
date: 2012-11-17 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|