Skip to content
  • Jean Boussier's avatar
    091dc78f
    Forward sql.active_record notifications back into the calling thread · 091dc78f
    Jean Boussier authored
    It is not uncommon for `sql.active_record` subscribers to rely on
    thread local or fiber local state. For instance the `buffered-logger`
    gem buffer the logs in a thread variable.
    
    With the introduction of async queries, the `sql.active_record`
    events can now be produced from a background thread and that break
    some expectations.
    
    This makes it hard for subscriber to map the event to the request
    or job that scheduled it.
    
    That is why I believe we should instead store the event and
    publish it back on the calling thread when the results are
    accessed.
    091dc78f
    Forward sql.active_record notifications back into the calling thread
    Jean Boussier authored
    It is not uncommon for `sql.active_record` subscribers to rely on
    thread local or fiber local state. For instance the `buffered-logger`
    gem buffer the logs in a thread variable.
    
    With the introduction of async queries, the `sql.active_record`
    events can now be produced from a background thread and that break
    some expectations.
    
    This makes it hard for subscriber to map the event to the request
    or job that scheduled it.
    
    That is why I believe we should instead store the event and
    publish it back on the calling thread when the results are
    accessed.
Loading