Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #799 (defect)

Opened 6 months ago

Last modified 6 months ago

_test_concurrency fails periodically

Status: closed (fixed)

Reported by: lakin Assigned to: fumanchu
Priority: normal Milestone: 3.1
Component: CherryPy code Keywords:
Cc:
lakin@zedd:~/Projects/cherrypy/trunk/cherrypy$ python test/test.py --test_session
Python version used to run this test script: 2.5.1
CherryPy version 3.1.0beta3
HTTP server version HTTP/1.1 
PID: 25410


Running tests: cherrypy._cpwsgi.CPWSGIServer
test (test_session.MemcachedSessionTest) ... ok
test_0_Session (test_session.SessionTest) ... ok
test_1_Ram_Concurrency (test_session.SessionTest) ... ok
test_2_File_Concurrency (test_session.SessionTest) ... FAIL
test_3_Redirect (test_session.SessionTest) ... ok
test_4_File_deletion (test_session.SessionTest) ... ok
test_5_Error_paths (test_session.SessionTest) ... ok
test_6_regenerate (test_session.SessionTest) ... ok

======================================================================
FAIL: test_2_File_Concurrency (test_session.SessionTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/webtest.py", line 278, in __call__
    testMethod()
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/test_session.py", line 180, in test_2_File_Concurrency
    self._test_Concurrency()
  File "/home/lakin/Projects/cherrypy/trunk/cherrypy/test/test_session.py", line 230, in _test_Concurrency
    self.assertEqual(hitcount, expected)
AssertionError: 148 != 151

FAILED (failures=1)
skipped
hit enter

Surprisingly it typically only happens with the FileSession?, although from looking at the tests itself it's obvious that there is a concurrency issue.

For instance: http://cherrypy.org/browser/trunk/cherrypy/test/test_session.py#L57

is not threadsafe. It would be easy for two threads to overwrite each others increments. For reference this is how the threads are created: http://cherrypy.org/browser/trunk/cherrypy/test/test_session.py#L182l

So, I'm not sure if the session is supposed guard against these sorts of concurrency issues, but my first impression is that it shouldn't. So I'd say the test is broken, thoughts?

Attachments

results.2.txt (94.2 kB) - added by lakin on 03/15/08 12:41:48.
Some tracings of various values during a failing run of the session test (with diff of prints)
results.txt (106.7 kB) - added by lakin on 03/15/08 12:58:27.
Some tracings of various values during a failing run of the session test (with diff of prints)

Change History

03/14/08 23:38:01: Modified by lakin

Aaah, nevermind, the cherrypy session tool should lock the session for the request. :)

03/14/08 23:43:31: Modified by lakin

This also explains why the RamSession? passes. It's locking mechanism is much more simple, and easier to verify that it is correct.

03/15/08 10:40:56: Modified by fumanchu

  • owner changed from rdelon to fumanchu.
  • status changed from new to assigned.
  • milestone set to 3.1.

Oh! I had only been getting this error when running with --ssl, so I figured it was an SSL-only problem. Good to have another avenue of attack now. :)

03/15/08 12:41:48: Modified by lakin

  • attachment results.2.txt added.

Some tracings of various values during a failing run of the session test (with diff of prints)

03/15/08 12:58:27: Modified by lakin

  • attachment results.txt added.

Some tracings of various values during a failing run of the session test (with diff of prints)

03/15/08 13:02:04: Modified by lakin

So, it appears the problem is a temporary error in parsing the pickle from the file, causing an EOF error which then causes a new session id to be generated. The problem starts here:

http://cherrypy.org/attachment/ticket/799/results.txt#L1080

03/16/08 10:33:43: Modified by fumanchu

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in [1924].

Hosted by WebFaction

Log in as guest/cpguest to create tickets