This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RDS uses a different query for killing transactions.
- Loading branch information
Phan Le and Ryan Tang
committed
May 3, 2013
1 parent
397e78b
commit bfdcfa9
Showing
8 changed files
with
86 additions
and
9 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
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,7 @@ | ||
module VCAP::Services::Mysql::RDS | ||
class TransactionKiller | ||
def kill(thread_id, connection) | ||
connection.query("CALL rds.kill(#{thread_id})") | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module VCAP::Services::Mysql::Standard | ||
class TransactionKiller | ||
def kill(id, connection) | ||
connection.query("KILL #{id}") | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require_relative 'rds/transaction_killer' | ||
require_relative 'standard/transaction_killer' | ||
|
||
module VCAP::Services::Mysql | ||
class TransactionKiller | ||
def self.build(provider) | ||
if provider == "rds" | ||
RDS::TransactionKiller.new | ||
else | ||
Standard::TransactionKiller.new | ||
end | ||
end | ||
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
12 changes: 12 additions & 0 deletions
12
ng/mysql/spec/mysql_service/rds/transaction_killer_spec.rb
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,12 @@ | ||
require 'spec_helper' | ||
require 'mysql_service/rds/transaction_killer' | ||
|
||
describe VCAP::Services::Mysql::RDS::TransactionKiller do | ||
describe "killing transaction" do | ||
it "should use the connection to kill" do | ||
connection = stub | ||
connection.should_receive(:query).with('CALL rds.kill(1)') | ||
subject.kill(1, connection) | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
ng/mysql/spec/mysql_service/standard/transaction_killer_spec.rb
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,12 @@ | ||
require 'spec_helper' | ||
require 'mysql_service/standard/transaction_killer' | ||
|
||
describe VCAP::Services::Mysql::Standard::TransactionKiller do | ||
describe "killing transaction" do | ||
it "should use the connection to kill" do | ||
connection = stub | ||
connection.should_receive(:query).with('KILL 1') | ||
subject.kill(1, connection) | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'spec_helper' | ||
require 'mysql_service/transaction_killer' | ||
|
||
describe VCAP::Services::Mysql::TransactionKiller do | ||
context "provider is RDS" do | ||
it "returns a rds killer" do | ||
described_class.build('rds'). | ||
should be_a(VCAP::Services::Mysql::RDS::TransactionKiller) | ||
end | ||
end | ||
|
||
context "provider is not specified" do | ||
it "returns the standard killer" do | ||
described_class.build(nil). | ||
should be_a(VCAP::Services::Mysql::Standard::TransactionKiller) | ||
end | ||
end | ||
end |