#13345 closed defect (fixed)
Functional tests sometimes randomly failing
| Reported by: | Jun Omae | Owned by: | Jun Omae |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.5.3 |
| Component: | general | Version: | 1.5.2 |
| Severity: | normal | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: |
Fix global shutdown crashes while creating new database connection. |
||
| API Changes: | |||
| Internal Changes: | |||
Description
We recently encountered random failures of functional tests on Travis CI. Probably, Proxy.get_source() in better_twill.py has something wrong, e.g race condition.
I'd like to fix the issue before release of 1.6 because it leads stopping release procedure when release tagging.
======================================================================
ERROR: runTest (trac.wiki.tests.functional.TestWikiDelete)
Delete a wiki page.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/edgewall/trac/trac/wiki/tests/functional.py", line 51, in runTest
tc.find("Are you sure you want to completely delete this page?")
File "/home/travis/build/edgewall/trac/trac/tests/functional/better_twill.py", line 191, in find
raise AssertionError("Regex didn't match: {!r} not found in {}"
AssertionError: Regex didn't match: 'Are you sure you want to completely delete this page?' not found in file:///home/travis/build/edgewall/trac/testenv/trac/log/TestWikiDelete.html
======================================================================
ERROR: runTest (trac.ticket.tests.functional.admin.TestAdminMilestoneDetail)
Admin modify milestone details
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/edgewall/trac/trac/ticket/tests/functional/admin.py", line 298, in runTest
self._tester.login('user')
File "/home/travis/build/edgewall/trac/trac/tests/functional/tester.py", line 50, in login
tc.find("Login")
File "/home/travis/build/edgewall/trac/trac/tests/functional/better_twill.py", line 191, in find
raise AssertionError("Regex didn't match: {!r} not found in {}"
AssertionError: Regex didn't match: 'Login' not found in file:///home/travis/build/edgewall/trac/testenv/trac/log/TestAdminMilestoneDetail.html
Attachments (0)
Change History (8)
follow-up: 6 comment:1 by , 5 years ago
comment:2 by , 5 years ago
Applying jomae.git@trunk:t13345, I get the following traceback in testenv/testing.log at https://travis-ci.com/github/jun66j5/trac/jobs/486246637. The db pool with PostgreSQL has something wrong.
127.0.0.1 - - [25/Feb/2021 16:06:33] "GET /milestone/SuckingSequential HTTP/1.1" 200 -
Traceback (most recent call last):
File "/home/travis/build/jun66j5/trac/trac/web/main.py", line 573, in dispatch_request
env = open_environment(env_path, use_cache=not run_once)
File "/home/travis/build/jun66j5/trac/trac/env.py", line 857, in open_environment
env.shutdown()
File "/home/travis/build/jun66j5/trac/trac/env.py", line 506, in shutdown
DatabaseManager(self).shutdown(tid)
File "/home/travis/build/jun66j5/trac/trac/db/api.py", line 551, in shutdown
self._cnx_pool.shutdown(tid)
File "/home/travis/build/jun66j5/trac/trac/db/pool.py", line 218, in shutdown
_backend.shutdown(tid)
File "/home/travis/build/jun66j5/trac/trac/db/pool.py", line 195, in shutdown
db.close()
AttributeError: 'tuple' object has no attribute 'close'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/travis/build/jun66j5/trac/trac/web/main.py", line 605, in dispatch_request
raise HTTPInternalServerError(env_error) from env_error
127.0.0.1 - - [25/Feb/2021 16:06:33] "GET /milestone/ChicleStylizes HTTP/1.1" 200 -
abc.HTTPInternalServerError: 500 Internal Server Error ('tuple' object has no attribute 'close')
127.0.0.1 - - [25/Feb/2021 16:06:33] "GET / HTTP/1.1" 500 -
follow-up: 8 comment:3 by , 5 years ago
Proposed changes in [086f3f21b/jomae.git].
The issue occurs when ConnectionPoolBackend.shutdown(None) is invoked while calling ConnectionPoolBackend.get_cnx(). The situation can occur because tracd is multi-thread server and webdriver uses multiple requests.
- The
.get_cnx()temporarily sets a tuple (e.g.('create', None)) to._active[(tid, key)]as deferred marker to reduce the time of locking_activeproperty. - After releasing the lock, it tries to connect database.
- While locking
_activeproperty, replace deferred marker in_active[]with real connection.
All of stable branches also have this issue.
I think ideally ConnectionPoolBackend.shutdown(None) invoked by changes of trac.ini should do after termination of current requests.
comment:5 by , 5 years ago
| Owner: | set to |
|---|---|
| Release Notes: | modified (diff) |
| Status: | new → assigned |
Committed in [17503].
comment:6 by , 5 years ago
I noticed another issue,
AssertionError: This pool has already been destroyed. I guess the issue raises on Trac 1.0 - 1.4 with Python 2 also.
I've filed in #13356.
comment:7 by , 5 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Looks like this is resolved so I'll close it.
comment:8 by , 5 years ago
I think ideally
ConnectionPoolBackend.shutdown(None)invoked by changes of trac.ini should do after termination of current requests.
At least, multitherading web server with SQLite crashes due to the behavior.
I've filed in #13390.



After the following patch:
.travis.yml
I found Internal Server Error in https://travis-ci.com/github/jun66j5/trac/jobs/486161318, however the
AttributeErroris not logged in testenv/testing.log nor testenv/trac/log/trac.log.I noticed another issue,
AssertionError: This pool has already been destroyed. I guess the issue raises on Trac 1.0 - 1.4 with Python 2 also.127.0.0.1 - - [25/Feb/2021 10:48:08] "GET /admin/versioncontrol/repository/t11618 HTTP/1.1" 200 - Exception ignored in: <function SubversionRepository.__del__ at 0x7f2bcbe18ca0> Traceback (most recent call last): File "/home/travis/build/jun66j5/trac/tracopt/versioncontrol/svn/svn_fs.py", line 412, in __del__ self.close() File "/home/travis/build/jun66j5/trac/tracopt/versioncontrol/svn/svn_fs.py", line 455, in close self.pool.destroy() File "/home/travis/build/jun66j5/trac/tracopt/versioncontrol/svn/svn_fs.py", line 211, in destroy self.apr_pool_destroy(self._pool) File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/svn/core.py", line 300, in svn_pool_destroy pool.destroy() File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/libsvn/core.py", line 9440, in destroy self.assert_valid() File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/libsvn/core.py", line 9426, in assert_valid assert self.valid(), "This pool has already been destroyed" AssertionError: This pool has already been destroyed Exception ignored in: <function Pool.__del__ at 0x7f2bcbe185e0> Traceback (most recent call last): File "/home/travis/build/jun66j5/trac/tracopt/versioncontrol/svn/svn_fs.py", line 222, in __del__ self.destroy() File "/home/travis/build/jun66j5/trac/tracopt/versioncontrol/svn/svn_fs.py", line 211, in destroy self.apr_pool_destroy(self._pool) File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/svn/core.py", line 300, in svn_pool_destroy pool.destroy() File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/libsvn/core.py", line 9440, in destroy self.assert_valid() File "/home/travis/virtualenv/python3.9.1/lib/python3.9/site-packages/libsvn/core.py", line 9426, in assert_valid assert self.valid(), "This pool has already been destroyed" AssertionError: This pool has already been destroyed