user warning: Duplicate entry '1' for key 1 query: INSERT INTO session_restore VALUES (1, 'a:6:{s:8:\"textsize\";s:2:\"70\";s:17:\"updates_remaining\";a:0:{}s:20:\"node_overview_filter\";a:0:{}s:18:\"ad_overview_filter\";a:0:{}s:21:\"dblog_overview_filter\";a:0:{}s:24:\"watchdog_live_latest_wid\";s:7:\"8363545\";}') in /var/www/web3/html/sites/all/modules/session_restore/session_restore.module on line 83.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | session_restore_race_condition-517884-4.patch | 2.41 KB | iva2k |
Comments
Comment #1
Zen commentedI am unable to replicate this. Please provide more information.
Comment #2
Zen commentedComment #3
iva2k commentedIt occasionally happens in 7.x:
It is hard to reproduce (had something to do with having open session logged in as admin, closing the browser, then reloading the browser and letting it restore the old session which opened a bunch of tabs on the website at once -- smells like a race condition).
What is obvious looking at the code is that there is a db_delete() prior to db_insert(), but there is no lock for multiple requests.
Comment #4
iva2k commentedThe appropriate code pattern here would be using lock_acquire()/lock_wait()/lock_release(), as used for example in menu_build() in core.
Please review the attached patch that wraps delete/save operations on database {session_restore} table.
I tested it and had no problems/errors in the log doing a browser close-restore with about 20 tabs pointing to the website.