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