Skip to content
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

error after creating connection pool and being IDLE for a while #75

Closed
MetaiR opened this issue Sep 20, 2019 · 6 comments
Closed

error after creating connection pool and being IDLE for a while #75

MetaiR opened this issue Sep 20, 2019 · 6 comments

Comments

@MetaiR
Copy link

MetaiR commented Sep 20, 2019

hi I am getting this error after creating a connection pool and put application IDLE for a while (I mean don't do anything with application) and it keeps coming

Uncaught (in promise) Error: (conn=1921, no: 45013, SQLState: 08S01) Cannot execute new commands: connection closed
sql: ROLLBACK
Uncaught (in promise) Error: (conn=1922, no: 45013, SQLState: 08S01) Cannot execute new commands: connection closed
sql: ROLLBACK
.
.
.

what's the problem?

btw: I am using mariadb 2.1.0 with a combination of Electronjs and angular to creating a desktop application and the error looks like is shown from zone.js file; here is the full stack trace:

zone.js:391 Uncaught (in promise) Error: (conn=1921, no: 45013, SQLState: 08S01) Cannot execute new commands: connection closed
sql: ROLLBACK
    at Object.module.exports.createError (F:\git\loan\node_modules\mariadb\lib\misc\errors.js:55)
    at _changeTransaction (F:\git\loan\node_modules\mariadb\lib\connection.js:945)
    at Connection.rollback (F:\git\loan\node_modules\mariadb\lib\connection.js:148)
    at Connection.conn.release (F:\git\loan\node_modules\mariadb\lib\pool-promise.js:74)
    at Connection.conn.releaseWithoutError (F:\git\loan\node_modules\mariadb\lib\pool-promise.js:50)
    at idleMaintainer (F:\git\loan\node_modules\mariadb\lib\pool-base.js:466)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (vendor.js:57205)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)

SQLError | @ | F:\git\loan\node_mod…ib\misc\errors.js:6
-- | -- | --
  | module.exports.createError | @ | F:\git\loan\node_mod…b\misc\errors.js:55
  | _changeTransaction | @ | F:\git\loan\node_mod…b\connection.js:945
  | Connection.rollback | @ | F:\git\loan\node_mod…b\connection.js:148
  | conn.release | @ | F:\git\loan\node_mod…\pool-promise.js:74
  | conn.releaseWithoutError | @ | F:\git\loan\node_mod…\pool-promise.js:50
  | idleMaintainer | @ | F:\git\loan\node_mod…ib\pool-base.js:466
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:423
  | onInvokeTask | @ | vendor.js:57205
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:422
  | push../node_modules/zone.js/dist/zone.js.Zone.runTask | @ | zone.js:195
  | push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask | @ | zone.js:498
  | ZoneTask.invoke | @ | zone.js:487
  | timer | @ | zone.js:2281
  | Promise.then (async) |   |  
  | scheduleMicroTask | @ | zone.js:584
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:413
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask | @ | zone.js:238
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask | @ | zone.js:258
  | scheduleResolveOrReject | @ | zone.js:879
  | ZoneAwarePromise.then | @ | zone.js:1012
  | setInterval (async) |   |  
  | scheduleTask | @ | zone.js:2302
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:410
  | onScheduleTask | @ | zone.js:301
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:404
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask | @ | zone.js:238
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleMacroTask | @ | zone.js:261
  | scheduleMacroTaskWithCurrentZone | @ | zone.js:1245
  | (anonymous) | @ | zone.js:2317
  | proto.(anonymous function) | @ | zone.js:1569
  | (anonymous) | @ | F:\git\loan\node_mod…ib\pool-base.js:147
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke | @ | zone.js:391
  | onInvoke | @ | vendor.js:57214
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke | @ | zone.js:390
  | push../node_modules/zone.js/dist/zone.js.Zone.run | @ | zone.js:150
  | (anonymous) | @ | zone.js:889
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:423
  | onInvokeTask | @ | vendor.js:57205
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask | @ | zone.js:422
  | push../node_modules/zone.js/dist/zone.js.Zone.runTask | @ | zone.js:195
  | drainMicroTaskQueue | @ | zone.js:601
  | processTicksAndRejections | @ | internal/process/task_queues.js:86
  | Promise.then (async) |   |  
  | scheduleMicroTask | @ | zone.js:584
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:413
  | onScheduleTask | @ | zone.js:301
  | push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask | @ | zone.js:404
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask | @ | zone.js:238
  | push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask | @ | zone.js:258
  | scheduleResolveOrReject | @ | zone.js:879
  | resolvePromise | @ | zone.js:825
  | (anonymous) | @ | zone.js:741
  | processTicksAndRejections | @ | internal/process/task_queues.js:81
@rusher
Copy link
Collaborator

rusher commented Sep 20, 2019

This seems to occur when a connection in pool close connection idle after reaching pool idleTimeout value (default to 30 minutes).

The problem here is that rollback command is normally done only if there is an existing transaction on connection but after pool.query or giving back a connection to pool, connection is reverted into a clean state, meaning that no rollback command is normally executed.

I can think only on initSql that change autocommit state or server equivalent (specifically autocommit query/ variables).
could you indicate pool configuration and server version and configuration relative to autocommit if changed ?

@MetaiR
Copy link
Author

MetaiR commented Sep 20, 2019

ommm, I didn't change any autocommit configurations. here is how I create the pool:

createPool() {
        this.pool = createPool({
            user: 'db-user',
            password: 'db-password',
            database: 'db',
            compress: true,
            charset: 'utf8mb4_persian_ci',
            resetAfterUse: false
        });
    }

I call this method at the very beginning of my application and then I get a new connection from pool by calling pool.getConnection();

---- update ----
I also added idleTimeout: 0 to my options and I am still getting the same error

@MetaiR
Copy link
Author

MetaiR commented Sep 21, 2019

@rusher any idea?

@rusher
Copy link
Collaborator

rusher commented Sep 23, 2019

finally understood and reproduced. This won't have any incidence but having those ERRORs logged.
Will be in next corrective version (2.1.2)

@MetaiR
Copy link
Author

MetaiR commented Sep 25, 2019

hoooorrrraaaaayyyy
so it was a bug? what is the problem?

@MetaiR MetaiR closed this as completed Sep 25, 2019
@rusher
Copy link
Collaborator

rusher commented Sep 26, 2019

Correction corresponds to this commit . When a connection from pool is not used for some time (>idleTimeout ) connection is closed (a QUIT command is issued, followed by a ROLLBACK / COM_RESET command if using callback implementation. ).
These command has no use and will be removed, resulting in this console log error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants