---
title: "发现ror中比较头痛的问题"
author: "yinter"
date: "2008-03-07T17:46:00Z"
tags: []
slug: "ror"
draft: false
lastmod: "2008-03-07T17:46:00Z"
id: 169207
url: "https://yinter.iteye.com/blog/169207"
---

前些日子在公司用rails开发了一个管理后台，但是给同事使用过程中，经常发现会使数据库被死锁，跟踪数据库发现是操作了一个"SELECT 1"，但思索不解其原因，后面就直接查询其源代码，
内容在"C:\ruby\lib\ruby\gems\1.8\gems\activerecord-2.0.2\lib\
active_record\connection_adapters\sqlserver_adapter.rb"(226,30):       @connection.execute("SELECT 1").finish处，
方法内容如下：
# CONNECTION MANAGEMENT ====================================#

      # Returns true if the connection is active.
      def active?
        @connection.execute("SELECT 1").finish
        true
      rescue DBI::DatabaseError, DBI::InterfaceError
        false
      end

估计是测试其数据库的连接，但还是没有解决问题，不知道大伙有没有遇到类似情况！