Throwing three non-pausing clients at mysql-backed EM server

is causing intermittent port binding problems which
manifest as an unreachable server.  Inserting a pause
on the client side fixes the problem.  Hm.
This commit is contained in:
Dan Buch 2012-06-16 01:07:53 -04:00
parent 8addb0fe6c
commit d67d1632a8
2 changed files with 28 additions and 8 deletions

View File

@ -1,11 +1,25 @@
require 'socket' require 'socket'
successes = 0
backoff = 0.5
loop do loop do
begin
TCPSocket.open('127.0.0.1', 22000) do |sock| TCPSocket.open('127.0.0.1', 22000) do |sock|
sock.send("sally #{rand(100)} #{rand(100)}\n", 0) sock.send("sally #{rand(101)} #{rand(101)}\n", 0)
sock.recv(100) sock.recv(100)
sock.close sock.close
STDOUT.write('.') STDOUT.write('.')
STDOUT.flush STDOUT.flush
end end
successes += 1
backoff = 0.5
sleep 0.01
rescue
STDOUT.write('E')
STDOUT.flush
STDERR.write("\nmade it #{successes} times. sleeping #{backoff} secs\n")
successes = 0
sleep backoff
backoff *= 2
end
end end

View File

@ -1,10 +1,16 @@
require 'eventmachine' require 'eventmachine'
require 'sequel' require 'sequel'
if ENV['MPDB']
DB = Sequel.connect(ENV['MPDB'])
else
DB = Sequel.connect('sqlite://marco-polo.sqlite3') DB = Sequel.connect('sqlite://marco-polo.sqlite3')
end
if DB[:locations].nil? begin
DB.create_table :locations do DB[:locations].empty?
rescue Sequel::DatabaseError
DB.create_table(:locations) do
primary_key :id primary_key :id
String :client String :client
Integer :x Integer :x