From fbd99e89f3d6b29ce829440717262bc03d567ca5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 10 May 2015 09:22:31 +0200 Subject: [PATCH] Added logging to find race condition. --- lib/sessions/backend/ticket_overview_index.rb | 13 +++++++++++++ lib/sessions/backend/ticket_overview_list.rb | 14 ++++++++++---- test/unit/session_basic_ticket_test.rb | 3 +++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/sessions/backend/ticket_overview_index.rb b/lib/sessions/backend/ticket_overview_index.rb index 2936e240f..e2bffebac 100644 --- a/lib/sessions/backend/ticket_overview_index.rb +++ b/lib/sessions/backend/ticket_overview_index.rb @@ -15,10 +15,17 @@ class Sessions::Backend::TicketOverviewIndex current_user: @user, ) + if !overview || overview.empty? + Rails.logger.debug "ERR no overview for #{@user.inspect}/#{overview.isnpect}" + end + # no data exists return if !overview # no change exists + if @last_change == overview + Rails.logger.debug "ERR @last_change == overview #{@user.inspect}/#{overview.isnpect}" + end return if @last_change == overview # remember last state @@ -33,6 +40,10 @@ class Sessions::Backend::TicketOverviewIndex def push + if Sessions::CacheIn.get( client_key ) + Rails.logger.debug "ERR CACHE FILLED #{@client_key}" + end + # check check interval return if Sessions::CacheIn.get( client_key ) @@ -41,11 +52,13 @@ class Sessions::Backend::TicketOverviewIndex # check if min one ticket has changed last_ticket_change = Ticket.latest_change + Rails.logger.debug "ERR last_ticket_change #{last_ticket_change}" return if last_ticket_change == @last_ticket_change @last_ticket_change = last_ticket_change # load current data data = load + Rails.logger.debug "ERR push/load #{data.inspect}" return if !data diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb index e85d8e185..978cb6115 100644 --- a/lib/sessions/backend/ticket_overview_list.rb +++ b/lib/sessions/backend/ticket_overview_list.rb @@ -24,7 +24,9 @@ class Sessions::Backend::TicketOverviewList data = { list: overview_data, index: overview } result.push data } - Rails.logger.debug "LOG A #{result.inspect}" + if !result || result.empty? + Rails.logger.debug "LOG A PROBLEM #{result.inspect} / #{@last_change}" + end # no data exists return if !result || result.empty? @@ -45,7 +47,9 @@ class Sessions::Backend::TicketOverviewList def push # check interval - Rails.logger.debug "LOG 1 #{@user.inspect}" + if Sessions::CacheIn.get( client_key ) + Rails.logger.debug "LOG 1 CACH KEY EXISTS #{@user.inspect}" + end return if Sessions::CacheIn.get( client_key ) # reset check interval @@ -54,13 +58,15 @@ class Sessions::Backend::TicketOverviewList # check if min one ticket has changed last_ticket_change = Ticket.latest_change - Rails.logger.debug "LOG 3 #{last_ticket_change}/#{@last_ticket_change}" + if last_ticket_change == @last_ticket_change + Rails.logger.debug "LOG 3 #{last_ticket_change}/#{@last_ticket_change}" + end return if last_ticket_change == @last_ticket_change @last_ticket_change = last_ticket_change # load current data items = load - Rails.logger.debug "LOG 4 #{items.inspect}" + Rails.logger.debug "LOG 4 set new from load #{items.inspect}" return if !items # push overviews diff --git a/test/unit/session_basic_ticket_test.rb b/test/unit/session_basic_ticket_test.rb index 35cb1ec68..42c31cb60 100644 --- a/test/unit/session_basic_ticket_test.rb +++ b/test/unit/session_basic_ticket_test.rb @@ -29,6 +29,9 @@ class SessionBasicTicketTest < ActiveSupport::TestCase # get as stream result1 = client1.push + if !result1 + Rails.logger.debug "FAILD Sessions::Backend::TicketOverviewIndex push" + end assert( result1, 'check ticket_overview_index' ) # next check should be empty / no changes