Hi, list I have newly migrated an Zope2 application to Zope3 and added session support to it. When I stress test the application with 'ab -c 20', I found lots of database conflict errors, like the following:
2008-03-20T13:44:24 WARNING ZopePublication Competing writes/reads at /prod/++vh++http:rhodium.homemaster.cn:80/++/products/bWc9MTAzJmI9NA==: database conflict error (oid 0x3e, class BTrees.OOBTree.OOBTree, serial this txn started with 0x03748ea6c0076ecc 2008-03-20 04:22:45.006805, serial currently committed 0x03748ef8667bc888 2008-03-20 05:44:24.019577) ------ 2008-03-20T13:44:24 WARNING ZopePublication Competing writes/reads at /prod/++vh++http:rhodium.homemaster.cn:80/++/products/bWc9MTAzJmI9NA==: database conflict error (oid 0x3e, class BTrees.OOBTree.OOBTree, serial this txn started with 0x03748ea6c0076ecc 2008-03-20 04:22:45.006805, serial currently committed 0x03748ef8667bc888 2008-03-20 05:44:24.019577) ------ 2008-03-20T13:44:25 WARNING ZopePublication Competing writes/reads at /prod/++vh++http:rhodium.homemaster.cn:80/++/products/bWc9MTAzJmI9NA==: database conflict error (oid 0x3e, class BTrees.OOBTree.OOBTree, serial this txn started with 0x03748ea6c0076ecc 2008-03-20 04:22:45.006805, serial currently committed 0x03748ef8667bc888 2008-03-20 05:44:24.019577) ------ 2008-03-20T13:44:39 WARNING ZODB.DB DB.open() has 8 open connections with a pool_size of 7 ------ 2008-03-20T13:44:45 WARNING ZopePublication Competing writes/reads at /prod/++vh++http:rhodium.homemaster.cn:80/++/products/bWc9MTAzJmI9NA==: database conflict error (oid 0x0dddaa, class BTrees.OOBTree.OOBucket, serial this txn started with 0x03748ef8b578d588 2008-03-20 05:44:42.532502, serial currently committed 0x03748ef8b90ef211 2008-03-20 05:44:43.373058) ------ 2008-03-20T13:44:46 WARNING ZopePublication Competing writes/reads at /prod/++vh++http:rhodium.homemaster.cn:80/++/products/bWc9MTAzJmI9NA==: database conflict error (oid 0x0ddda9, class BTrees.OOBTree.OOBucket, serial this txn started with 0x03748ef89d390a55 2008-03-20 05:44:36.849097, serial currently committed 0x03748ef8c043debb 2008-03-20 05:44:45.062137) ...... The more complex the test page, i.e. the longer time necessary to generate a response, the more conflicts appear. Looking into the ZODB, I found all conflicts appears at the OOBTree or OOBucket, and they all contain session data: >>> root._p_jar['\x00\x00\x00\x00\x00\x00\x00\x3e'] <BTrees.OOBTree.OOBTree object at 0x9f8fdac> >>> root._p_jar['\x00\x00\x00\x00\x00\x0d\xdd\xaa'] BTrees.OOBTree.OOBucket([('Zjos3EZS4oOyLAUejl0Xq9RT7woV12BLc.C8dekKCAkDPcCMdqGwA8', <zope.session.session.SessionData object at 0x9f9202c>), ('aDS7b33CWWptgPYJCbCJlhcoQjkt--SmeM4pF2XiyDGvdc9C9diTcE', <zope.session.session.SessionData object at 0x9f9206c>), ('an5bfNkL6oO0oHb1K7oHMyrqhvoOzVNKP7UKKBSssZ8-CDRhRDiiig', <zope.session.session.SessionData object at 0x9fdc76c>), ('bGG4E2jhbIQ6EYETT9JHa0.ZP4IjIQtJ1XNQK19ORKfb3ov5AHoasg', <zope.session.session.SessionData object at 0x9fdc82c>), ('cfxKsIw58f.KqESglVi63G3YdLgGGsduMr9m1HEDAZZN7QXJQKqTT8', <zope.session.session.SessionData object at 0x9f920ac>), ('cuHZ4PyRSGi9WvaITuVo9.f5yYU3lrDS4Rw0VEI5MzL1KDzzIDg7cA', <zope.session.session.SessionData object at 0x9fdc86c>), ('d4CDu80Z4PENLYqrwpYQcJrEHtI9SQkdxh7jOisN0ecEeyk78S-l-Y', <zope.session.session.SessionData object at 0x9fdc7ec>), ('d5h4xVFiTRWy.f9-fl9Phc6PeZs.m-XpPQnt9kfuzt6tRKzol-M8DM', <zope.session.session.SessionData object at 0x9f920ec>), ('ea88VW0qmh04ZCFJIrxRbkOBOssMBxm463xEDb43zjg-sgJTpkEoyo', <zope.session.session.SessionData object at 0x9f9212c>), ('eloivtXMl5DR9lb1pDGC5OvrN445kqNRndJb9BcqBEVajLF5SQIWg4', <zope.session.session.SessionData object at 0x9f9216c>), ('emx7d9RFeccvwmsym6NkajLvKxcNhp1xXmK09C-kZvYHO5ySZ1CniY', <zope.session.session.SessionData object at 0x9fdc7ac>), ('f4wqdTRhqcjjifYjSdKByOMad9M7taFSNMohD9xNUuP5PGBCBUo1Bg', <zope.session.session.SessionData object at 0x9f9256c>), ('g0i978GRti5oj70Mb9ks0nLEMHcj0iE0s3NCT2lpjfFBm73-Ta1ktM', <zope.session.session.SessionData object at 0x9f925ec>), ('hJYayepksKCz1xtg71S7bQ2z9MEYhaXLFNfgqNu590cpBW3dArz6sA', <zope.session.session.SessionData object at 0x9f921ac>), ('hW9EjQ9I7SqAAf3oG9zPHA2oFWA.pzJ.1bREzWycu9mM8P-RExT8W0', <zope.session.session.SessionData object at 0x9f925ac>), ('hWUnyqPLXYifg4-Ryo5i37-u3yoRte6Le6ryKq1saVQHFVfLl82tXY', <zope.session.session.SessionData object at 0x9f921ec>), ('iHGEuaZoRIh5raxPad2hbh91jkIQ2GYtl3-tuzmYaLiLbbXYJqLAIc', <zope.session.session.SessionData object at 0x9f9252c>), ('iqUTsBAdXWssU1hwqQ-BLrOoS-MbBtGqNzRI5wKGWfOAIVnVnhtxJo', <zope.session.session.SessionData object at 0x9f9222c>), ('jKGjdchCGugHfJwgsyDwqpQKLOgMx15hSs5u89kni01VlXmTY4B3S4', <zope.session.session.SessionData object at 0x9f9226c>), ('knbHBxhaT.6mhdf3HXSiZWuqdSMq.yjaXPt4KIi.J0JcPT1uf5uj9s', <zope.session.session.SessionData object at 0x9f922ac>), ('mXy-i3ucYsmTIDoD7d9Yfe3Ii90CjLvNEjJQx6aTbeTBfccm7m9lys', <zope.session.session.SessionData object at 0x9f9262c>)]) So I guess the following is what happened: With -c 20, multiple simultaneous requests are trying to access their session. Since session object is created and stored into the PersistentSessionDataContainer upon first access, there are multiple thread trying to add new session data into the persistent session data container, which uses an OOBTree to store the session data. Now comes the part that I can not understand. This simultaneous adding to the BTree seem to cause the conflict error, since the BTree and Bucket are also persistent object themselves. This would mean that ZODB is not suitable for the cases of simultanous adding to a BTree by multiple threads, like in my case for session data. But since ZODB and zope.session are so widely used, I can not image that this could be the case, otherwise how can anyone be reliably using ZODB for session? So I must be missing some very important points. Please be so kind to tell me what I should do to make my application stable in regard of the above problem. I am using Zope 3.4 under Linux. -- Hong Yuan 大管家网上建材超市 装修装潢建材一站式购物 http://www.homemaster.cn
_______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users