node.js - How to properly handle connection persistent things within node-mysql connection pooling -


if use node-mysql's connection pooling feature, wouldn't pose problem in app because connections re-used after connection.end()? here's why i'm concerned: when define variable in sql, or start transaction, variable or transaction persistent until connection closed. since connection never closed, instead re-used, variables , transactions can seep routine doesn't expect variable or expect transaction exist; expects fresh connection.

variables pose big problem; routine never safely assume variable undefined because connection wear , tear.

transactions pose bigger issue if 1 routine ever fail rollback or commit transaction before calling end(). if next routine use connection doesn't deal transactions, queries appended transaction , halted, never executed. careful when writing app such error never occurs, mistakes happen, , if happen, it'd extremely difficult debug (i wouldn't know routine mishandling connections, bad bad).

so these of concerns when thinking using pooling. surely i'm not person have thought of these issues, please shed light on how handle pooled connections, if you'd kind. :)

thank much.

all transactions happen in context of single connection. after end or terminate connection, can no longer operate on transaction. general pattern open, query, close , unless have long running transaction, won't have problems of queries or variables bleeding on other connections.

in event of long running transaction, have manage connection object make sure exists , used code operates within transaction.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -