rails-pg-adapter 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +12 -0
 - data/lib/rails_pg_adapter/patch.rb +28 -25
 - data/lib/rails_pg_adapter/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b84b17ac8e8008860499554d460faba310b74cad9ab1121a47ae3546ce07869e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: f60cd6ef5bd5a9d87ef55d51840d75ae0142ef3c3d86e14aed523784b2147b57
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7bc8312c2fa2ab807ebcc197b1f3e0e61bc700fe7b451e436c6667470f2df0a7300c773715ea7cc15fac75b0dba322ef67dedcedc135d479a139b1d4ec251ec0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: dfb8e3d337d0905639f67cfb84101b0bad1232152d838238373b4ac0abca0e5256a174585b8866f424119b157597e5730e0e03a48f14989d67c8c9a92f0e8491
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## [0.1.12] - 2023-05-08
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            - Slight refactor and reduce multiple disconnect attempts
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## [0.1.11] - 2023-05-08
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - Attempt a re-connect before a retry
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ## [0.1.10] - 2023-05-04
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            - Handle Connection refused
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       1 
13 
     | 
    
         
             
            ## [0.1.9] - 2023-05-04
         
     | 
| 
       2 
14 
     | 
    
         | 
| 
       3 
15 
     | 
    
         
             
            - Retry on too many connections error as well
         
     | 
| 
         @@ -43,42 +43,52 @@ module RailsPgAdapter 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
                def exec_cache(*args)
         
     | 
| 
       45 
45 
     | 
    
         
             
                  sleep_times = ::RailsPgAdapter.configuration.reconnect_with_backoff.dup
         
     | 
| 
      
 46 
     | 
    
         
            +
                  query, _ = args
         
     | 
| 
       46 
47 
     | 
    
         
             
                  begin
         
     | 
| 
       47 
48 
     | 
    
         
             
                    super(*args)
         
     | 
| 
       48 
49 
     | 
    
         
             
                  rescue ::ActiveRecord::StatementInvalid,
         
     | 
| 
       49 
50 
     | 
    
         
             
                         ::ActiveRecord::ConnectionNotEstablished,
         
     | 
| 
       50 
51 
     | 
    
         
             
                         ::ActiveRecord::NoDatabaseError => e
         
     | 
| 
       51 
52 
     | 
    
         
             
                    raise unless ::RailsPgAdapter::Patch.supported_errors?(e)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    handle_schema_cache_error(e)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    handle_activerecord_error(e)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    raise unless try_reconnect?(e)
         
     | 
| 
       52 
56 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                     
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                       
     | 
| 
       56 
     | 
    
         
            -
                      warn("Retry query failed, retrying again in #{sleep_time} sec.")
         
     | 
| 
      
 57 
     | 
    
         
            +
                    sleep_time = sleep_times.shift
         
     | 
| 
      
 58 
     | 
    
         
            +
                    if sleep_time
         
     | 
| 
      
 59 
     | 
    
         
            +
                      warn("Retry query failed, retrying again in #{sleep_time} sec. Retrying: #{query}")
         
     | 
| 
       57 
60 
     | 
    
         
             
                      sleep(sleep_time)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      connect
         
     | 
| 
       58 
62 
     | 
    
         
             
                      retry
         
     | 
| 
       59 
63 
     | 
    
         
             
                    else
         
     | 
| 
       60 
     | 
    
         
            -
                       
     | 
| 
      
 64 
     | 
    
         
            +
                      handle_activerecord_error(e)
         
     | 
| 
      
 65 
     | 
    
         
            +
                      raise
         
     | 
| 
       61 
66 
     | 
    
         
             
                    end
         
     | 
| 
       62 
67 
     | 
    
         
             
                  end
         
     | 
| 
       63 
68 
     | 
    
         
             
                end
         
     | 
| 
       64 
69 
     | 
    
         | 
| 
       65 
70 
     | 
    
         
             
                def exec_no_cache(*args)
         
     | 
| 
       66 
71 
     | 
    
         
             
                  sleep_times = ::RailsPgAdapter.configuration.reconnect_with_backoff.dup
         
     | 
| 
      
 72 
     | 
    
         
            +
                  query, _ = args
         
     | 
| 
       67 
73 
     | 
    
         
             
                  begin
         
     | 
| 
       68 
74 
     | 
    
         
             
                    super(*args)
         
     | 
| 
       69 
75 
     | 
    
         
             
                  rescue ::ActiveRecord::StatementInvalid,
         
     | 
| 
       70 
76 
     | 
    
         
             
                         ::ActiveRecord::ConnectionNotEstablished,
         
     | 
| 
       71 
77 
     | 
    
         
             
                         ::ActiveRecord::NoDatabaseError => e
         
     | 
| 
       72 
78 
     | 
    
         
             
                    raise unless ::RailsPgAdapter::Patch.supported_errors?(e)
         
     | 
| 
      
 79 
     | 
    
         
            +
                    handle_schema_cache_error(e)
         
     | 
| 
      
 80 
     | 
    
         
            +
                    handle_activerecord_error(e)
         
     | 
| 
      
 81 
     | 
    
         
            +
                    raise unless try_reconnect?(e)
         
     | 
| 
       73 
82 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
                     
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                       
     | 
| 
       77 
     | 
    
         
            -
                      warn("Retry query failed, retrying again in #{sleep_time} sec.")
         
     | 
| 
      
 83 
     | 
    
         
            +
                    sleep_time = sleep_times.shift
         
     | 
| 
      
 84 
     | 
    
         
            +
                    if sleep_time
         
     | 
| 
      
 85 
     | 
    
         
            +
                      warn("Retry query failed, retrying again in #{sleep_time} sec. Retrying: #{query}")
         
     | 
| 
       78 
86 
     | 
    
         
             
                      sleep(sleep_time)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      connect
         
     | 
| 
       79 
88 
     | 
    
         
             
                      retry
         
     | 
| 
       80 
89 
     | 
    
         
             
                    else
         
     | 
| 
       81 
     | 
    
         
            -
                       
     | 
| 
      
 90 
     | 
    
         
            +
                      handle_activerecord_error(e)
         
     | 
| 
      
 91 
     | 
    
         
            +
                      raise
         
     | 
| 
       82 
92 
     | 
    
         
             
                    end
         
     | 
| 
       83 
93 
     | 
    
         
             
                  end
         
     | 
| 
       84 
94 
     | 
    
         
             
                end
         
     | 
| 
         @@ -87,28 +97,21 @@ module RailsPgAdapter 
     | 
|
| 
       87 
97 
     | 
    
         
             
                  return false if in_transaction?
         
     | 
| 
       88 
98 
     | 
    
         
             
                  return false unless ::RailsPgAdapter::Patch.failover_error?(e.message)
         
     | 
| 
       89 
99 
     | 
    
         
             
                  return false unless ::RailsPgAdapter.reconnect_with_backoff?
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                  begin
         
     | 
| 
       92 
     | 
    
         
            -
                    disconnect_conn!
         
     | 
| 
       93 
     | 
    
         
            -
                    true
         
     | 
| 
       94 
     | 
    
         
            -
                  rescue ::ActiveRecord::ConnectionNotEstablished
         
     | 
| 
       95 
     | 
    
         
            -
                    false
         
     | 
| 
       96 
     | 
    
         
            -
                  end
         
     | 
| 
      
 100 
     | 
    
         
            +
                  true
         
     | 
| 
       97 
101 
     | 
    
         
             
                end
         
     | 
| 
       98 
102 
     | 
    
         | 
| 
       99 
     | 
    
         
            -
                def  
     | 
| 
       100 
     | 
    
         
            -
                   
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                  end
         
     | 
| 
      
 103 
     | 
    
         
            +
                def handle_activerecord_error(e)
         
     | 
| 
      
 104 
     | 
    
         
            +
                  return unless ::RailsPgAdapter::Patch.failover_error?(e.message)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  warn("clearing connections due to #{e} - #{e.message}")
         
     | 
| 
      
 106 
     | 
    
         
            +
                  disconnect_conn!
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
       105 
108 
     | 
    
         | 
| 
      
 109 
     | 
    
         
            +
                def handle_schema_cache_error(e)
         
     | 
| 
       106 
110 
     | 
    
         
             
                  return unless ::RailsPgAdapter::Patch.missing_column_error?(e.message)
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
111 
     | 
    
         
             
                  warn("clearing column information due to #{e} - #{e.message}")
         
     | 
| 
       109 
112 
     | 
    
         | 
| 
       110 
113 
     | 
    
         
             
                  internal_clear_schema_cache!
         
     | 
| 
       111 
     | 
    
         
            -
                  raise
         
     | 
| 
      
 114 
     | 
    
         
            +
                  raise(e)
         
     | 
| 
       112 
115 
     | 
    
         
             
                end
         
     | 
| 
       113 
116 
     | 
    
         | 
| 
       114 
117 
     | 
    
         
             
                def disconnect_conn!
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rails-pg-adapter
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.12
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tines Engineering
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-05-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     |