TimeoutError: Unable to get database connection within 0 seconds. (TracError(,))

当你在 trac(An enhanced wiki and issue tracking system for software projects) 0.12 上启用某个插件后,比如 trac-mastertickets-3.0.1(Support for ticket dependencies),可能会要求你执行 trac-admin project_environment_path upgrade 以创建缺少的数据库表,比如 mastertickets。

如果你是使用 Apache 作为 web 前端,PostgreSQL(而不是默认的 sqlite) 作为后端存储的话,当执行完上述命令后,再用浏览器查看 trac 的时候可能会得到下面的错误信息:

Traceback (most recent call last):
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/api.py", line 440, in send_error
    data, 'text/html')
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/chrome.py", line 827, in render_template
    message = req.session.pop('chrome.%s.%d' % (type_, i))
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/api.py", line 216, in __getattr__
    value = self.callbacks[name](self)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/main.py", line 300, in _get_session
    return Session(self.env, req)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/session.py", line 203, in __init__
    self.get_session(req.authname, authenticated=True)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/session.py", line 219, in get_session
    super(Session, self).get_session(sid, authenticated)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/web/session.py", line 61, in get_session
    db = self.env.get_db_cnx()
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/env.py", line 328, in get_db_cnx
    return get_read_db(self)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/db/api.py", line 90, in get_read_db
    return _transaction_local.db or DatabaseManager(env).get_connection()
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/db/api.py", line 152, in get_connection
    return self._cnx_pool.get_cnx(self.timeout or None)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/db/pool.py", line 226, in get_cnx
    return _backend.get_cnx(self._connector, self._kwargs, timeout)
  File "build/bdist.freebsd-8.1-RELEASE-amd64/egg/trac/db/pool.py", line 146, in get_cnx
    raise TimeoutError(errmsg)
TimeoutError: Unable to get database connection within 0 seconds. (TracError(,))

根据上述错误信息,你可能会去检查数据库连接问题,并且百查不得头绪。其实是因为 trac 无法读取 conf/trac.ini 所致。

执行 trac-admin upgrade 之前,trac.ini的权限及属主信息如下:

-rw-------  1 www  www  4998 10 31 23:20 conf/trac.ini

而执行完成后,其权限变成了:

-rw-------  1 root  www  4998 10 31 23:20 conf/trac.ini

因为属主变成了 root,且 Apache 工作进程所在的用户组 www 的权限为g:---,所以 Apache 无法读取 trac.ini,从而导致了上述错误的产生。

解决方法:

chown www conf/trac.ini

如果错误依旧,尝试重启动 Apache 试试:

apachectl restart
Advertisements

#apache-http-server, #postgresql, #trac

Subversion 1.7 的 WC 结构变化后 svn info 输出的变化

Subversion 1.6:
$ svn info
路径: .
URL: https://example.com/svn/foobar/trunk
版本库根: https://example.com/svn/foobar
版本库 UUID: 45048e1e-2893-e011-ba6f-00163e041e7a
版本: 297
节点种类: 目录
调度: 正常
最后修改的作者: jobs
最后修改的版本: 297
最后修改的时间: 2011-10-23 01:53:47 +0800 (日, 2011-10-23)

Subversion 1.7:
$ svn info
路径: .
工作副本根目录: /Users/jobs/Documents/workspace/foobar
URL: https://example.com/svn/foobar/trunk
版本库根: https://example.com/svn/foobar
版本库 UUID: 45048e1e-2893-e011-ba6f-00163e041e7a
版本: 297
节点种类: 目录
调度: 正常
最后修改的作者: jobs
最后修改的版本: 297
最后修改的时间: 2011-10-23 01:53:47 +0800 (三, 2011-10-23)

svn info 的输出中确实是多出一个“工作副本根目录”。

#subversion

Amazon EC2 t1.micro ubench

Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk
http://www.phystech.com/download/ubench.html
FreeBSD 8.2-RC1 FreeBSD 8.2-RC1 #11: Sat Jan 8 02:12:50 UTC 2011 root@chch.daemonology.net:/usr/obj/i386/usr/src/sys/XEN i386
Ubench CPU: 17445
Ubench MEM: 1427
——————–
Ubench AVG: 9436

#ubench

Xen – WARP .50@PhotonVPS ubench

Dedicated RAM: 256MB
SWAP: 512MB
CPU Cores: 2

Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk
http://www.phystech.com/download/ubench.html
FreeBSD 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:36:49 UTC 2010 root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
Ubench CPU: 287641
Ubench MEM: 20687
——————–
Ubench AVG: 154164

#photonvps, #ubench

苹果维修后网上在线调查结束后的32种语言的“谢谢”

取回了修好键盘的 MacBook Air 后的约第4天,收到苹果的邮件收集维修反馈,做完反馈后的最后一页是32种语言的“谢谢”。

网页截图:

原图:

原图地址:http://bibz05.apple.com:8080/ssurvey/sfilemanager/ThankYou.gif

现在变成32种语言了,以前是21种的。

HTML 代码(其中 jquery.js 加载了两次嘛):

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head onLoad= loadCSS();>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link type="image/x-icon" rel="icon" href="sfilemanager/favicon.ico">
	 <script src="js/jquery-1.4.4.js" type="text/javascript"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link type="image/x-icon" rel="icon" href="sfilemanager/favicon.ico">

<script src="js/thankyou.js" type="text/javascript"></script>
	<script src="js/jquery.min.js" type="text/javascript"></script>

<meta name="viewport" content="user-scalable=no, width=device-width" />

</head>

<body class='thankyouBody'>

<div id="wrapper" class='thankyouWrapper'>

<div id='' class='thankyouHeader'>
</div>
<!-- <div id='main' align=center style='margin-top:-85px'> -->
<div class = 'thankYouImagePosition'>
<!-- <img src="./sfilemanager/ThankYou.gif" alt="Thank You" style='display:block' class='resizeForIPhone'> -->

</div>
<div id='footer'></div>
</div>

</body>
</html>

服务器貌似用的 JBoss-5.0:

$ curl -v 'http://bibz05.apple.com:8080/ssurvey/nsurvey.html?id=BA8F704'
* About to connect() to bibz05.apple.com port 8080 (#0)
*   Trying 17.112.144.106... connected
> GET /ssurvey/nsurvey.html?id=BA8F704 HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-apple-darwin10.8.0) libcurl/7.22.0 OpenSSL/1.0.0e zlib/1.2.5 libidn/1.22
> Host: bibz05.apple.com:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
< Accept-Ranges: bytes
< ETag: W/"1334-1315545066000"
< Last-Modified: Fri, 09 Sep 2011 05:11:06 GMT
< Content-Type: text/html
< Content-Length: 1334
< Date: Thu, 13 Oct 2011 18:19:56 GMT

#apple, #jboss, #jquery, #servlet

安装 twip(svn revision 204)的 O 模式的几个注意点

  1. 在 twitter 网站申请 oauth key 的时候一定要在 Callback URL 里填写点东西,不能留空,否则在 twip 上验证 OAtuh 的时候会得到错误:
    Could not connect to Twitter. Refresh the page or try again later.
    Error code:401.

    我是通过在 http://code.google.com/p/twip/source/browse/trunk/include/twitteroauth.php#82 把 $token 打印出来发现问题的原因的,twip 只给出个Error code:401,但是具体的原因没有给出:

    Array
    (
        [ "1.0" encoding="UTF-8"?>
    
      Desktop applications only support the oauth_callback value 'oob'
      /oauth/request_token?oauth_callback=https://example.com/twip/oauth.php
        [amp;oauth_consumer_key] => blah
        [amp;oauth_nonce] => blah
        [amp;oauth_signature] => blah
        [amp;oauth_signature_method] => HMAC-SHA1
        [amp;oauth_timestamp] => 1318523087
        [amp;oauth_version] => 1.0
    
    
    )
    Could not connect to Twitter. Refresh the page or try again later.
     Error code:401.
    
  2. 必须在 php.ini 里启用 php_openssl.dll ,否则会得到如下错误:
    file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?

#openssl, #php, #twip, #twitter

取回了修好了键盘的 MacBook Air

等了好久都没有等到苹果零售店的通知,包括邮件和电话通知都没有。

昨天,登录其网站上查看修理状态,发现早在我送去修理的第二天9月30日就 repair complete 了,但是很奇怪到现在都没有通知我。我开始怀疑网站上的信息是不是准确,于是打零售店的电话确认了一下,打入时有8个人在我前面排队等待人工接听电话,等了10分钟终于轮到我了。确认确实修好了。

因为在保修期内且不是因为人为损坏所以修理是免费的:

取的时候在零售店里遇到两个温州的小伙子,他们有一个 iPhone 没有声音了,从温州赶到浦东零售店来修理,但是因为其固件是越狱过的,bar 台不给修理,虽然再三要求 bar 台帮忙刷机成官方非越狱固件,但是在刷机的过程中总是失败,不知何故,于是他们向我借电脑刷固件,按照普通的流程就刷回了官方的固件。因此我在零售店里多逗留了约45分钟。

离开时,我注意到门口有鲜花、苹果、蜡烛,是果粉悼念乔布斯的:

#macbook-air