connect-session-sequelize icon indicating copy to clipboard operation
connect-session-sequelize copied to clipboard

Fix out of sync Session Table in Read replica

Open icetr8 opened this issue 6 months ago • 0 comments

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: true option 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

icetr8 avatar Jun 09 '25 05:06 icetr8