<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-35  評論-33  文章-0  trackbacks-0

          已經(jīng)一個(gè)多月沒有寫東西了,不過最近確實(shí)很忙。前兩天在線上碰到一個(gè)C3P0的鏈接死鎖的異常,話說這個(gè)上古神物 ,我已經(jīng)是很久不碰了。先貼異常



    異常截圖

    "apparent deadlocks":名詞解釋是說c3p0拿到鏈接之后,最終使用之后沒有返回到pool,導(dǎo)致死鏈檢測失敗。經(jīng)過在stack Overflow檢索,https://stackoverflow.com/questions/3730844/c3p0-apparent-deadlock-when-the-threads-are-all-empty.發(fā)現(xiàn)增加一個(gè)statementCacheNumDeferredCloseThreads該參數(shù)的定義,就可以避免這個(gè)問題。

    經(jīng)過查看官方文檔:http://www.mchange.com/projects/c3p0/#statementCacheNumDeferredCloseThreads



    解釋:如果把該值設(shè)為超過1,statement的緩存就會自動跟蹤當(dāng)前可用的connections,如果沒有再用,就會自動銷毀掉。如果需要另外的線程來專門銷毀緩存的statement,則還需要設(shè)置maxStatements與maxStatementsPerConnection。

    再貼一個(gè)官方的說明:

    Configuring Statement Pooling

    c3p0 implements transparent PreparedStatement pooling as defined by the JDBC spec. Under some circumstances, statement pooling can dramatically improve application performance. Under other circumstances, the overhead of statement pooling can slightly harm performance. Whether and how much statement pooling will help depends on how much parsing, planning, and optimizing of queries your databases does when the statements are prepared. Databases (and JDBC drivers) vary widely in this respect. It's a good idea to benchmark your application with and without statement pooling to see if and how much it helps.

    You configure statement pooling in c3p0 via the following configuration parameters:

    maxStatements

    maxStatementsPerConnection

    statementCacheNumDeferredCloseThreads

    maxStatementsis JDBC's standard parameter for controlling statement pooling.maxStatementsdefines the total numberPreparedStatementsa DataSource will cache. The pool will destroy the least-recently-used PreparedStatement when it hits this limit. This sounds simple, but it's actually a strange approach, because cached statements conceptually belong to individual Connections; they are not global resources. To figure out a size formaxStatementsthat does not "churn" cached statements, you need to consider the number offrequently usedPreparedStatements in your application,and multiply that by the number of Connections you expect in the pool (maxPoolSizein a busy application).

    maxStatementsPerConnectionis a non-standard configuration parameter that makes a bit more sense conceptually. It defines how many statements each pooled Connection is allowed to own. You can set this to a bit more than the number ofPreparedStatementsyour applicationfrequentlyuses, to avoid churning.

    If either of these parameters are greater than zero, statement pooling will be enabled. If both parameters are greater than zero, both limits will be enforced. If only one is greater than zero, statement pooling will be enabled, but only one limit will be enforced.

    大概意思就是這兩個(gè),有一個(gè)值如果大于0,c3p0的statement pool就會發(fā)生作用。

    以上所有的配置都是基于c3p0的最新版本。PS一下,還是2015年的JAR。



    通過引入最新的C3P0包,另外增加了兩段配置,線上觀察兩天,問題解決。



    最后打個(gè)小廣告,JAVA世界最快的JDBC連接池,非HikariCP莫屬。已經(jīng)甩c3p0好幾個(gè)街角,有圖有真像。





    我的微信公眾號,歡迎溝通學(xué)習(xí)。
    posted on 2017-11-10 15:25 alexcai 閱讀(1810) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 国产亚洲成av片在线观看| 亚洲国产精品成人久久蜜臀| 久久精品国产69国产精品亚洲| 国产成人+综合亚洲+天堂| 狠狠久久永久免费观看| 九九精品国产亚洲AV日韩| 国产精品免费视频一区| 国产AV无码专区亚洲AV琪琪| 四虎成人精品在永久免费| 色一情一乱一伦一视频免费看| 亚洲成A人片77777国产| gogo免费在线观看| 亚洲精品中文字幕无码蜜桃| 外国成人网在线观看免费视频| 精品亚洲成AV人在线观看| 国产桃色在线成免费视频| 亚洲精品国产av成拍色拍| 亚洲国产一成久久精品国产成人综合 | 精品一区二区三区免费视频| 亚洲av片一区二区三区| 久久国产免费直播| 亚洲综合日韩中文字幕v在线| 五月婷婷在线免费观看| 亚洲日本成本人观看| 亚洲av午夜精品一区二区三区| AAAAA级少妇高潮大片免费看| 亚洲国产成人久久综合碰碰动漫3d| 69pao强力打造免费高清| 中文字幕无码亚洲欧洲日韩| 国产性生交xxxxx免费| 热久久这里是精品6免费观看| 综合自拍亚洲综合图不卡区| 免费黄色网址入口| 两性色午夜视频免费播放| 亚洲无限乱码一二三四区| 免费人成视频x8x8入口| 久久A级毛片免费观看| 深夜特黄a级毛片免费播放| 老司机亚洲精品影院无码| 成人永久免费高清| 久久久久成人片免费观看蜜芽 |