-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record not able to insert properly using pool.query #3286
Comments
Are you using transactions anywhere? If you leave a client in an open transaction state without committing it or rolling it back before returning it to the pool, that transaction will never be committed, but other queries that happen to check out the same client will see its effects. |
Hello, sorry for late reply,
I think after client.release if there is no commit. rollback automatically happen right ? |
Yeah definitely need a rollback there in catch. otherwise if there is an
error your txn will be left open but the client will be released back to
the pool
…On Mon, Aug 5, 2024 at 7:38 AM sawrubgupta ***@***.***> wrote:
Hello, sorry for late reply,
So wherever the API needs transaction I uses transaction and at other
places I use simple pool.query
So you are saying, whenever error occurs in error case I should use
ROLLBACK ?
This is my transaction API body
import pool from './db'
const client = await poo.connect();
try{
await client.query('BEGIN');
// all the client querty executes here
await client.query("COMMIT");
}catch(){
}finally{
client.release();
}
—
Reply to this email directly, view it on GitHub
<#3286 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMHINX37K2YDQDY4BWKB3ZP5P47AVCNFSM6AAAAABLWFUZNKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRYHA3DKNBZGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Yes, I added rollback everywhere in my code where i am using transaction, weird issues are coming up in code . suppose sometime code is stuck at const rows = await client.query(sql, val); the code dont go below these lines, idk its issue with db or transsaction Now this issue also comes sometimes
|
Guys please help, Its really scary, customer enters data but its not entering |
Hello I have been using this library for more than 2 years but never faced this issue but in this few weeks I am facing a issue problem
I am using database pooling
this is my configuration
Now issue is I hit a create record api and then hit list record api, everything work perfectly fine till now but after some seconds, my newly inserted record disappears automatically.
No delete query is running
sometimes it work and sometimes it doesnt.
List of whatplugin api
Now after hitting createWhatPlugin we hit whatPluginList api, and data comes in list api but after sometimes data automatically disappear.
I believe maybe its library issue ? can you please let me know 🙏
The text was updated successfully, but these errors were encountered: