Skip to content
  • eileencodes's avatar
    2aa33bbd
    Ensure the reading connection always raises if we try to write · 2aa33bbd
    eileencodes authored
    Manual backport of 2c07d162.
    
    Since test fixtures share connections (due to transactional tests) we
    end up overwriting the reading configuration so Rails doesn't recognize
    it as a replica connection.
    
    This change ensures that if we're using the `reading` role that
    connections will always have prevent writes turned on.
    
    If you need a replica connection that does not block writes, you should
    use a different role name other than `:reading`.
    
    The db selector test and connection handlers test have been updated to
    test for these changes. In the db selector test we don't always have a
    writing handler so I updated test fixtures to return if that's nil.
    
    Lastly one test needed to be updated to use a different handler name due
    to it needing to write to successfully test what it needs to test.
    
    Fixes #37765
    2aa33bbd
    Ensure the reading connection always raises if we try to write
    eileencodes authored
    Manual backport of 2c07d162.
    
    Since test fixtures share connections (due to transactional tests) we
    end up overwriting the reading configuration so Rails doesn't recognize
    it as a replica connection.
    
    This change ensures that if we're using the `reading` role that
    connections will always have prevent writes turned on.
    
    If you need a replica connection that does not block writes, you should
    use a different role name other than `:reading`.
    
    The db selector test and connection handlers test have been updated to
    test for these changes. In the db selector test we don't always have a
    writing handler so I updated test fixtures to return if that's nil.
    
    Lastly one test needed to be updated to use a different handler name due
    to it needing to write to successfully test what it needs to test.
    
    Fixes #37765
Loading