Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSfOQ-0005yH-0F for psycopg@arkaria.postgresql.org; Mon, 20 May 2019 10:19:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSfOO-0000aD-OD for psycopg@arkaria.postgresql.org; Mon, 20 May 2019 10:19:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSfOO-0000a6-Bb for psycopg@lists.postgresql.org; Mon, 20 May 2019 10:19:40 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSfOL-0006Xb-MX for psycopg@postgresql.org; Mon, 20 May 2019 10:19:39 +0000 Received: by mail-lj1-x232.google.com with SMTP id w1so11958894ljw.0 for ; Mon, 20 May 2019 03:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c3MxS0J2nSXOFikYvqOjPj/O2hDic7qTVc4AbDA0f7o=; b=uwliSNKSI/9yyEO5xhhN9KnG7ZLPavNOF0q1TE1pzaEaDQccBbh33dAPGJxWc2OS7K RZBbQTVEn8ie7QkWF2yv3fJfwOf1N0pa11NQ8oTjuD08CS9PpIiv6WSR7YZJ4fBuSAPj fQXXP/GOxTs18zcV4Tkq2WXejczA98bEnFPEMb93UXZdpQsSZdJXGnTFAxV/79iRIJ8V Lhue8Y4phJz/J6rf0E0eRissWdLo9bSe0cKqAysiGymqX6ejZ32ilJRIKLIdpvbiQs+x uz49ka5BuWaviFW4PNukpO0A4O9U67wKAFKHnmGpZhC1Jv688eZRuLsI5H+sNxu02Kqk uQeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c3MxS0J2nSXOFikYvqOjPj/O2hDic7qTVc4AbDA0f7o=; b=WjPT++16TXH0QT7WsrlgoDHiHoWPQPri3selZqAEJdpz6iYVRJpxz/cDwkyk81M17U PZMX8vrf4bky6+vJinFkXBUphCab34aRHGm2LxndaHiSkMYyKjyr6rUd7tTvBj0QchJ7 qHk5xvMc0NeirJARqD1x1IyNmPnFT2SDoYN6BZGTK5DsHNfFnRoGOSUZsbmNw3vdkzAp aw7ggFmn1nlbN2HrpsCWqR/BYK+yk4c4iDaoEV7MASEFYGXGLOyaOmE96QgAjIV+95kz /xXUaiDr2ulfP4chJPHyFq2oqK+w2RTuG0qngAImEyk0a7homyMp4GLU5sZptm821yEV TlFQ== X-Gm-Message-State: APjAAAU0BUrMUCAKviS4ZGNXi2w1EOurbmyib+T5+a4gBwFz9xvQVUdd mxkZVRbLHbKAdtVGE4wzCuTZQbG5csS697ilqb8= X-Google-Smtp-Source: APXvYqyBfTBURq7hsn9FGlT6GaxeXxoc3qlOCnyulLQVjlyyBNNxod3uwF1rNLmqrL1ax+wmnzFfsnF3v4YIgxSRZbY= X-Received: by 2002:a2e:995:: with SMTP id 143mr28409914ljj.92.1558347576068; Mon, 20 May 2019 03:19:36 -0700 (PDT) MIME-Version: 1.0 References: <46505a4b-517b-0967-c2f9-1364a794ecef@thomas-guettler.de> In-Reply-To: <46505a4b-517b-0967-c2f9-1364a794ecef@thomas-guettler.de> From: Daniele Varrazzo Date: Mon, 20 May 2019 19:19:24 +0900 Message-ID: Subject: Re: Log Stacktrace of current Python Interpreter via PostgreSQL trigger To: =?UTF-8?Q?Thomas_G=C3=BCttler?= Cc: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="000000000000b5500505894f11f9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000b5500505894f11f9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable If you use postgres logging in stored procedures you can retrieve the logs in 'connection.notices'. http://initd.org/psycopg/docs/connection.html#connection.notices On Mon, 20 May 2019, 16:40 Thomas G=C3=BCttler, wrote: > I am hunting a non reproducible in a production environment. > > I can detect the buggy change in a postgres trigger. > > Since it is production code I must no raise an exception. I can > only use logging. > > If I could see the stacktrace of the python interpreter, I could > see which codes the change which I am hunting. > > But how to get this interpreter stacktrace, if the condition is > detect in the db trigger? > > > > https://stackoverflow.com/questions/51873708/log-stacktrace-of-python-in-= postgresql-trigger > > Maybe there is a psycopg2 feature which I don't know up to now. > > I guess LISTEN+NOTIFY could get used. > Or setting a connection variable which I check after each SQL statement. > > Ideas welcome, > > Thomas G=C3=BCttler > > > -- > Thomas Guettler http://www.thomas-guettler.de/ > I am looking for feedback: > https://github.com/guettli/programming-guidelines > > > --000000000000b5500505894f11f9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
If you use postgres logging in stored procedures you can = retrieve the logs in 'connection.notices'.
On Mon, 20 May 2019, 16:40 Thomas G=C3=BCttler, &= lt;guettliml@thomas-guettle= r.de> wrote:
I am hunting a = non reproducible in a production environment.

I can detect the buggy change in a postgres trigger.

Since it is production code I must no raise an exception. I can
only use logging.

If I could see the stacktrace of the python interpreter, I could
see which codes the change which I am hunting.

But how to get this interpreter stacktrace, if the condition is
detect in the db trigger?


https://stackoverflow.com/questions/51873708/log-stacktrace-of-python-in-= postgresql-trigger

Maybe there is a psycopg2 feature which I don't know up to now.

I guess LISTEN+NOTIFY could get used.
Or setting a connection variable which I check after each SQL statement.
Ideas welcome,

=C2=A0 =C2=A0Thomas G=C3=BCttler


--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://githu= b.com/guettli/programming-guidelines


--000000000000b5500505894f11f9--