Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't set Logger Level when not using contexts #252

Open
martindsouza opened this issue Jul 19, 2021 · 1 comment
Open

Can't set Logger Level when not using contexts #252

martindsouza opened this issue Jul 19, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@martindsouza
Copy link
Member

martindsouza commented Jul 19, 2021

Change:

procedure null_global_contexts 
  is 
    pragma autonomous_transaction; 
    l_pref_value logger_prefs.pref_value%type;
  begin 
    $if $$no_op or $$rac_lt_11_2 or not $$logger_context $then 
      null; 
    $else 
     -- TODO THIS IS THE FIX
      select lp.pref_value
      into l_pref_value
      from logger_prefs lp
      where 1=1
        and lp.pref_type = 'LOGGER'
        and lp.pref_name = 'GLOBAL_CONTEXT_NAME'
      ;

      if l_pref_value != 'NONE' then
        dbms_session.clear_all_context(namespace => g_context_name); 
      end if;
    $end 
 
    commit; 
  end null_global_contexts; 

Same logic is needed in: save_global_context

procedure save_global_context(
    p_attribute in varchar2,
    p_value in varchar2,
    p_client_id in varchar2 default null)
  is
    pragma autonomous_transaction;
    l_pref_value logger_prefs.pref_value%type;
  begin
    $if $$no_op $then
      null;
    $else
      select lp.pref_value
      into l_pref_value
      from logger_prefs lp
      where 1=1
        and lp.pref_type = 'LOGGER'
        and lp.pref_name = 'GLOBAL_CONTEXT_NAME'
      ;
      
      if l_pref_value != 'NONE' then
        dbms_session.set_context(
          namespace => g_context_name,
          attribute => p_attribute,
          value => p_value,
          client_id => p_client_id);
      end if;
    $end

    commit; -- MD: moved commit to outside of the NO_OP check since commit or rollback must occur in this procedure
  exception

Should just have a function of is_context_enabled_yn or something that these procedures can use

@martindsouza martindsouza self-assigned this Jul 19, 2021
@martindsouza martindsouza added this to the 3.2.0 milestone Jul 20, 2021
@prinznamor
Copy link

Hello Mr. D'Souza,

a function of is_context_enabled_yn is a good idea.
We are using our database with ORDS and got thousands of requests each hour.
For each request we are setting the database session identifier to the X-Correlation-ID by using dbms_session.set_identifier.
Although for our production database we have set LOGGER-Level to OFF, the global context was saved by Logger for each request within the function ok_to_log which was for example called by a logger.log.
Our problem is, that the procedure unset_client_level, called by the scheduler job LOGGER_UNSET_PREFS_BY_CLIENT, will not clear the context for this client identifiers, because there exist no entries for this within the table logger_prefs_by_client_id. This causes millions of entries within the global context and after a week the database reported problems with the shared pool (ORA-04031).
Sure, we could add a call to the procedure LOGGER.set_level after the call of dbms_session.set_identifier to ensure that the client identifier will be added into the table logger_prefs_by_client_id. But I think it would be useful to check if the context is enabled before adding the values to the global context, if anybody uses dbms_session.set_identifier who do not know the consequences in context with the package LOGGER.
Currently we disabled the package LOGGER within the production database by recompiling with the flag no_op.

Best regards

Roman Vogt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants