db: fix data race in session update

Fix #284.