From 8506e1a1e1912eca4ab206bd3caa828dde02d6c0 Mon Sep 17 00:00:00 2001 From: Claas Beyersdorf Date: Thu, 5 Jan 2023 18:53:26 +0100 Subject: [PATCH 1/5] reverted f4df72c from SIPX-865 this change did not fix the problem but has negative sideeffects --- sipXcdr/lib/cdr.rb | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/sipXcdr/lib/cdr.rb b/sipXcdr/lib/cdr.rb index f123ced2eb..cd2e527ca6 100644 --- a/sipXcdr/lib/cdr.rb +++ b/sipXcdr/lib/cdr.rb @@ -360,19 +360,6 @@ def accept_call_transfer(cse) end def accept_call_end(cse) - # set fields unless previous events were caught and fields already set - @from_tag = cse.from_tag if !@from_tag - @caller_aor = cse.caller_aor if !@caller_aor - @callee_aor = cse.callee_aor if !@callee_aor - @start_time = cse.event_time if !@start_time - @reference = cse.reference if !@reference - @caller_internal = cse.caller_internal if !@caller_internal - @caller_contact = Utils.contact_without_params(cse.contact) if !@caller_contact - @via_count = cse.via_count if !@via_count - @branch_id = cse.branch_id if !@branch_id - @callee_route = cse.callee_route if !@callee_route - @callee_contact = cse.contact if !@callee_contact - @legs.accept_end(cse) finish end From 5f6590dc53e04e12c3320943576a4311ecd56fb9 Mon Sep 17 00:00:00 2001 From: Claas Beyersdorf Date: Thu, 5 Jan 2023 19:07:00 +0100 Subject: [PATCH 2/5] fix for [SIPX-865] calls with e.g. 404 SIP Responses will marked as terminated this creates correct CDRs for failed calls again. --- sipXcdr/lib/cdr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sipXcdr/lib/cdr.rb b/sipXcdr/lib/cdr.rb index cd2e527ca6..7efcc8b4ee 100644 --- a/sipXcdr/lib/cdr.rb +++ b/sipXcdr/lib/cdr.rb @@ -239,7 +239,7 @@ def complete? end def terminated? - @termination == CALL_COMPLETED_TERM || @termination == CALL_UNKNOWN_COMPLETED_TERM || @termination == CALL_TRANSFERRED_TERM || @termination == CALL_ABANDONED_TERM + @termination == CALL_COMPLETED_TERM || @termination == CALL_FAILED_TERM || @termination == CALL_UNKNOWN_COMPLETED_TERM || @termination == CALL_TRANSFERRED_TERM || @termination == CALL_ABANDONED_TERM end # Return a text description of the termination status for this CDR. From 90f486c9ad5fe032e03e3b7b3e335e03a8a0226a Mon Sep 17 00:00:00 2001 From: Claas Beyersdorf Date: Fri, 6 Jan 2023 15:42:24 +0100 Subject: [PATCH 3/5] Revert "fix for [SIPX-865]" This reverts commit 5f6590dc53e04e12c3320943576a4311ecd56fb9. --- sipXcdr/lib/cdr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sipXcdr/lib/cdr.rb b/sipXcdr/lib/cdr.rb index 7efcc8b4ee..cd2e527ca6 100644 --- a/sipXcdr/lib/cdr.rb +++ b/sipXcdr/lib/cdr.rb @@ -239,7 +239,7 @@ def complete? end def terminated? - @termination == CALL_COMPLETED_TERM || @termination == CALL_FAILED_TERM || @termination == CALL_UNKNOWN_COMPLETED_TERM || @termination == CALL_TRANSFERRED_TERM || @termination == CALL_ABANDONED_TERM + @termination == CALL_COMPLETED_TERM || @termination == CALL_UNKNOWN_COMPLETED_TERM || @termination == CALL_TRANSFERRED_TERM || @termination == CALL_ABANDONED_TERM end # Return a text description of the termination status for this CDR. From f0c7a164d3e2a32c0e96c5fe3347d32906b9f3e3 Mon Sep 17 00:00:00 2001 From: Claas Beyersdorf Date: Fri, 6 Jan 2023 15:42:51 +0100 Subject: [PATCH 4/5] workaround for [SIPX-865] it looks like the used cleaner -> terminator stuff is not working anymore the whole cleanup processes aren't executed at all (as far as I can see and debug) This workaround works. One should check if the used dependencies have changend and cause the problems. --- sipXcdr/lib/call_resolver.rb | 17 ++++------------- sipXcdr/lib/state.rb | 13 +++++++++++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sipXcdr/lib/call_resolver.rb b/sipXcdr/lib/call_resolver.rb index d982c8c0e4..6d3d247692 100644 --- a/sipXcdr/lib/call_resolver.rb +++ b/sipXcdr/lib/call_resolver.rb @@ -35,9 +35,6 @@ def initialize(config) end install_signal_handler(@readers) @writer = CdrWriter.new(@config.cdr_database_url, @config.purge_age_cdr, log) - @long_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:retire_long_calls, @config.max_call_len]) - @long_ringing_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:retire_long_ringing_calls, @config.max_ringing_call_len]) - @failed_calls_cleaner = Cleaner.new(@config.min_cleanup_interval, [:flush_failed_calls, @config.max_failed_wait]) @state = nil end @@ -71,20 +68,14 @@ def resolve(start_time, end_time) end end - long_calls_cleaner_thread = Thread.new(@long_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - failed_calls_cleaner_thread = Thread.new(@failed_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - long_ringing_calls_cleaner_thread = Thread.new(@long_ringing_calls_cleaner, cse_queue) do |cleaner, queue| - cleaner.run(queue) - end - # state copies from CSE queue to CDR queue @state = State.new(cse_queue, cdr_queue) @state.log = @log + @state.max_call_len = @config.max_call_len + @state.max_ringing_call_len = @config.max_ringing_call_len + @state.max_failed_wait = @config.max_failed_wait + Thread.new( @state ) do | state | state.run end diff --git a/sipXcdr/lib/state.rb b/sipXcdr/lib/state.rb index 6906f67453..2f9a42c086 100644 --- a/sipXcdr/lib/state.rb +++ b/sipXcdr/lib/state.rb @@ -27,7 +27,7 @@ def initialize(cdr, generation) end end - attr_writer :log + attr_writer :log, :max_call_len, :max_ringing_call_len, :max_failed_wait def initialize(cse_queue, cdr_queue, cdr_class = Cdr) @cse_queue = cse_queue @@ -58,7 +58,16 @@ def run else accept(item) #@log.debug("state.rb:: Accepted #{item}") if @log - end + end + + # run background tasks (this should run in own tasks but currently this does not work + # with the old code (maybe the dependencies have changed because of the update to ruby-2.0.0 ? + # this is meant as an workaround but I was not able to solve it differently + # and this works + # and as ruby is one threaded in base this should not change anything regards runtime... + retire_long_calls(@max_call_len) + retire_long_ringing_calls(@max_ringing_call_len) + flush_failed_calls(@max_failed_wait) end flush_failed() @cdr_queue << nil From f03debb145e6628989759ad6b3bdba6eaa93fe26 Mon Sep 17 00:00:00 2001 From: Claas Beyersdorf Date: Tue, 10 Jan 2023 11:07:33 +0100 Subject: [PATCH 5/5] - removed stop for non existing background jobs - added TODO comment --- sipXcdr/lib/call_resolver.rb | 5 ----- sipXcdr/lib/state.rb | 3 +++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sipXcdr/lib/call_resolver.rb b/sipXcdr/lib/call_resolver.rb index 6d3d247692..2e1bf24b21 100644 --- a/sipXcdr/lib/call_resolver.rb +++ b/sipXcdr/lib/call_resolver.rb @@ -103,11 +103,6 @@ def resolve(start_time, end_time) log.debug("call_resolver.rb:: CSE Readers threads stopped.") log.debug("call_resolver.rb:: CSEs in Queue = #{cse_queue.size()}") - # stop running housekeeping jobs - @long_calls_cleaner.stop - @failed_calls_cleaner.stop - @long_ringing_calls_cleaner.stop - ThreadsWait.all_waits(long_calls_cleaner_thread, failed_calls_cleaner_thread, long_ringing_calls_cleaner_thread) log.debug("call_resolver.rb:: Clean-up threads stopped.") diff --git a/sipXcdr/lib/state.rb b/sipXcdr/lib/state.rb index 2f9a42c086..738e3c8561 100644 --- a/sipXcdr/lib/state.rb +++ b/sipXcdr/lib/state.rb @@ -60,6 +60,9 @@ def run #@log.debug("state.rb:: Accepted #{item}") if @log end + # TODO: we should check for the min distance between runs... + # so that we reduce runtime + # run background tasks (this should run in own tasks but currently this does not work # with the old code (maybe the dependencies have changed because of the update to ruby-2.0.0 ? # this is meant as an workaround but I was not able to solve it differently