connect-session-sequelize
connect-session-sequelize copied to clipboard
Fix out of sync Session Table in Read replica
Issue
- In using sequelize and postgres with read replica as the database. The query of session by sessionId sometimes would be empty.
- The cause was that the Read replica is not up to date with the master. Sequelize would used the read replica on read queries as default.
Fix
- The change was implemented by adding the
useMaster: trueoption to the database query. This ensures that the most up-to-date data is being used
There is also a similar merged PR related to using read replica https://github.com/mweibel/connect-session-sequelize/pull/145
I was not able to replicate the fix in https://github.com/mweibel/connect-session-sequelize-example because my setup is on postgres. However when testing on my application, the query would now be always on the Master Database