davisp commented on issue #1182: fixed race is_idle
URL: https://github.com/apache/couchdb/pull/1182#issuecomment-368977110
 
 
   Aha! I was reading back through history and staring at this code to remind 
myself how this fits together and I realized that this isn't actually the right 
bug. The issue here is actually that we're doing a dirty read on the ets table 
and then attempting to take the monitor in an unprotected section. The proposed 
issues we've had here won't ever actually help us (other than the retry being a 
possible bandaid that'd likely fix it well enough).
   
   The dirty read issue becomes apparent when I finally remembered that 
couch_db_updater always monitors couch_file. So what must have happened is that 
couch_db_updater sent the close_db_if_idle cast which gets processed just after 
a client reads the db record from the ets table. What should really happen is 
that the monitor is taken while the client has locked the db entry in the 
couch_dbs table. Which is similar-ish to the proposal to insert/delete pids 
from that table.
   
   However, actually doing that makes things *really* slow (I've tried it for 
other reasons). And also fairly complicated as you then have the possibility 
where clients die during a "transaction" which then leaves your table with 
permanent locks and so on and such forth.
   
   I've run across this for some other reason I can't remember as well. And 
I've never been able to figure out a fix that doesn't cripple the throughput of 
couch_server. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to