MagicStack / MagicStack/asyncpg

LOG: could not receive data from client: Connection reset by peer

オープン
#736 コメント 2 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
8.1k
フォーク
468
PR マージ指標
30日以内にマージされた PR はありません

説明

* **asyncpg version**: 0.22.0
* **PostgreSQL version**: 12
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: AWS Aurora . Cannot reproduce with a local PostgreSQL.
* **Python version**: v3.7.6+
* **Platform**:
* **Do you use pgbouncer?**: No
* **Did you install asyncpg with pip?**: Yes
* **If you built asyncpg locally, which version of Cython did you use?**: N/A
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: just uvloop

It seems like asyncpg's connection pooler is not gracefully terminating connections. This seems to happen only with AWS Aurora version, but not the locally installed Postgres version.

Aurora Postgre has `idle_in_transaction_session_timeout` set to `86400000`.

Here is the code to help reproduce this issue. .

```
from sanic import Sanic, Blueprint
from sanic.exceptions import NotFound
from sanic.response import json
from sanic.handlers import ErrorHandler
import asyncpg

app = Sanic(name="asyncpg-errors")
bp = Blueprint("info", url_prefix="/info")

DB_CONFIG = {
'host':,
'user': ,
'password': ,
'port': 5432,
'database': 'postgres'
}

def log_listener(connection, message):
print(message)

@app.listener('before_server_start')
async def init(app, loop):
app.pool = await asyncpg.create_pool(
**DB_CONFIG, loop=loop,
max_size=10, max_inactive_connection_lifetime=1
)

@bp.route('/', methods=['GET'])
async def info(request):
async with request.app.pool.acquire() as conn:
conn.add_log_listener(log_listener)
d = await conn.fetchrow('''SELECT * FROM mmrtest limit 1''')
return json(dict(d))

group = Blueprint.group(bp)
app.blueprint(group)

app.run(port=9091, access_log=True, debug=True)

```

```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された Sanic の再現コードから始め、asyncpg.create_pool、max_inactive_connection_lifetime、および接続の取得/解放パスに注目してください。AWS Aurora に対して実行し、uvloop 上のローカル PostgreSQL と挙動を比較してください。接続リセットの挙動が説明され、検証済みの修正または範囲を限定した次のステップが文書化されていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
postgresql, python
領域
backend, databases
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。