* mored ebugs
This commit is contained in:
parent
c4f691b6d0
commit
a82181b63d
|
|
@ -18,13 +18,16 @@ module JamRuby
|
||||||
def self.active_record_transaction
|
def self.active_record_transaction
|
||||||
|
|
||||||
manager = self.new
|
manager = self.new
|
||||||
|
@log.debug("DEBUGCONN -1")
|
||||||
ActiveRecord::Base.connection_pool.with_connection do |connection|
|
ActiveRecord::Base.connection_pool.with_connection do |connection|
|
||||||
|
@log.debug("DEBUGCONN -2")
|
||||||
# create a transaction, and pass the current connection to ConnectionManager.
|
# create a transaction, and pass the current connection to ConnectionManager.
|
||||||
# this lets the entire operation work with the same transaction,
|
# this lets the entire operation work with the same transaction,
|
||||||
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
|
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
|
||||||
manager.pg_conn = connection.instance_variable_get("@connection")
|
manager.pg_conn = connection.instance_variable_get("@connection")
|
||||||
|
|
||||||
if @@in_websocket_gateway
|
if @@in_websocket_gateway
|
||||||
|
@log.debug("DEBUGCONN -3")
|
||||||
# it only necessary to catch exceptions in websocket-gateway, which has only one AR connection and does not clean it up like a Rails context does
|
# it only necessary to catch exceptions in websocket-gateway, which has only one AR connection and does not clean it up like a Rails context does
|
||||||
begin
|
begin
|
||||||
connection.transaction do
|
connection.transaction do
|
||||||
|
|
@ -34,7 +37,9 @@ module JamRuby
|
||||||
ActiveRecord::Base.connection.execute('ROLLBACK')
|
ActiveRecord::Base.connection.execute('ROLLBACK')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@log.debug("DEBUGCONN -4")
|
||||||
connection.transaction do
|
connection.transaction do
|
||||||
|
@log.debug("DEBUGCONN -5")
|
||||||
yield manager
|
yield manager
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -403,15 +403,20 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def join_music_session(user, client_id, music_session, as_musician, tracks, audio_latency, video_sources=nil)
|
def join_music_session(user, client_id, music_session, as_musician, tracks, audio_latency, video_sources=nil)
|
||||||
|
@log.debug("DEBUGCONN 1")
|
||||||
connection = nil
|
connection = nil
|
||||||
|
|
||||||
ConnectionManager.active_record_transaction do |connection_manager|
|
ConnectionManager.active_record_transaction do |connection_manager|
|
||||||
|
@log.debug("DEBUGCONN 2")
|
||||||
db_conn = connection_manager.pg_conn
|
db_conn = connection_manager.pg_conn
|
||||||
|
|
||||||
|
@log.debug("DEBUGCONN 3")
|
||||||
connection = Connection.find_by_client_id_and_user_id!(client_id, user.id)
|
connection = Connection.find_by_client_id_and_user_id!(client_id, user.id)
|
||||||
|
|
||||||
|
@log.debug("DEBUGCONN 4")
|
||||||
connection.join_the_session(music_session, as_musician, tracks, user, audio_latency, video_sources)
|
connection.join_the_session(music_session, as_musician, tracks, user, audio_latency, video_sources)
|
||||||
|
|
||||||
|
@log.debug("DEBUGCONN 5")
|
||||||
JamRuby::MusicSessionUserHistory.join_music_session(user.id, music_session.id)
|
JamRuby::MusicSessionUserHistory.join_music_session(user.id, music_session.id)
|
||||||
# connection.music_session_id = music_session.id
|
# connection.music_session_id = music_session.id
|
||||||
# connection.as_musician = as_musician
|
# connection.as_musician = as_musician
|
||||||
|
|
@ -420,14 +425,18 @@ SQL
|
||||||
# associate_tracks(connection, tracks)
|
# associate_tracks(connection, tracks)
|
||||||
# connection.save
|
# connection.save
|
||||||
|
|
||||||
|
@log.debug("DEBUGCONN 6")
|
||||||
if connection.errors.any?
|
if connection.errors.any?
|
||||||
|
@log.debug("DEBUGCONN 7")
|
||||||
raise ActiveRecord::Rollback
|
raise ActiveRecord::Rollback
|
||||||
else
|
else
|
||||||
|
@log.debug("DEBUGCONN 8")
|
||||||
update_session_controller(music_session.id)
|
update_session_controller(music_session.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@log.debug("DEBUGCONN 9")
|
||||||
connection
|
connection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue