Re: How to get transaction started always in WRITE mode.

From: Adam Šlachta <adam(dot)slachta(at)xitee(dot)com>
To: 'Scott Mead' <scottm(at)openscg(dot)com>, 'PostgreSQL General' <pgsql-general(at)postgresql(dot)org>
Cc: 'Martin Zítko' <martin(dot)zitko(at)xitee(dot)com>, 'Grigor Riskov' <grigor(dot)riskov(at)xitee(dot)com>, 'Milan Šiler' <milan(dot)siler(at)xitee(dot)com>
Subject: Re: How to get transaction started always in WRITE mode.
Date: 2017-07-25 14:27:01
Message-ID: 79d344f8-9d3b-4f67-b752-260d40da21ba@xitee.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Scott and other potential readers/writers,

> Login to the database with psql as the same user that your java app connects with try:
>
> show default_transaction_read_only;
> This can be set per-user, it's possible you're getting tripped up there.

show default_transaction_read_only;
OFF -> this was run under the same user as our application while the application was running;

> Also, what happens if you run:
>
> select pg_is_in_recovery();
> This can happen if you connect to a postgres slave instead of a master. Make sure you're always connecting to a master node for executing writes.

select pg_is_in_recovery() returns “F”, however we have not configured master/slave (I guess this is mostly used for replication right?).

> Is it possible that your code / connect layer is setting default_transaction_read_only to TRUE when the app connects?

Well, this might be hard to tell, since we would have to be sure all those layers (hibernate/spring) does not “somehow” set read-only to true. We have tried to set it up correctly, but most probably that’s where the problem root cause is.
Do you know how to find it out eg. in PostgreSQL logs how the read-only flag is setup for current transaction? We have tried to enable full logging (postgresql.conf) however reading it is quite tough and we did not get any closer to the solution.

Thank you for your help so far,
Adam

-------------------------------------------
This e-mail message including any attachments is for the sole use of the intended recipient(s) and may contain privileged or confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please immediately contact the sender by reply e-mail and delete the original message and destroy all copies thereof.

Tato zpráva včetně veškerých příloh je důvěrná a mohou ji využít pouze osoby, jimž je adresována. Nejste-li adresátem zprávy, obsah i s přílohami a kopiemi bezodkladně odstraňte ze svého systému a dále ji nijak nevyužívejte. Upozorňujeme Vás, že využívání zpráv, které Vám nejsou určeny, je zakázáno, včetně jejich přímého či nepřímého zveřejňování, kopírování, tištění, rozšiřování anebo jakéhokoli právního jednání učiněného při spoléhání se na jejich obsah. Pokud jste zprávu obdrželi omylem, postupujte stejně a neprodleně informujte odesílatele.

Der Inhalt dieser E-Mail ist vertraulich und ausschließlich für den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, dass jede Form der Kenntnisnahme, Veröffentlichung, Vervielfältigung oder Weitergabe des Inhalts dieser E-Mail unzulässig ist. Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message PAWAN SHARMA 2017-07-25 16:53:51 getting error while parsing log file using pgbadger
Previous Message Krithika Venkatesh 2017-07-25 14:20:44 Re: Partitioning (constraint exclusion involving joins)