File tree Expand file tree Collapse file tree 5 files changed +13
-45
lines changed Expand file tree Collapse file tree 5 files changed +13
-45
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ export default class ConnectionHolder {
70
70
71
71
this . _referenceCount -- ;
72
72
if ( this . _referenceCount === 0 ) {
73
- // release a connection without muting ACK_FAILURE, this is the last action on this connection
74
- return this . _releaseConnection ( true ) ;
73
+ return this . _releaseConnection ( ) ;
75
74
}
76
75
return this . _connectionPromise ;
77
76
}
@@ -85,9 +84,7 @@ export default class ConnectionHolder {
85
84
return this . _connectionPromise ;
86
85
}
87
86
this . _referenceCount = 0 ;
88
- // release a connection and mute ACK_FAILURE, this might be called concurrently with other
89
- // operations and thus should ignore failure handling
90
- return this . _releaseConnection ( false ) ;
87
+ return this . _releaseConnection ( ) ;
91
88
}
92
89
93
90
/**
@@ -97,14 +94,10 @@ export default class ConnectionHolder {
97
94
* @return {Promise } - promise resolved then connection is returned to the pool.
98
95
* @private
99
96
*/
100
- _releaseConnection ( sync ) {
97
+ _releaseConnection ( ) {
101
98
this . _connectionPromise = this . _connectionPromise . then ( connection => {
102
99
if ( connection ) {
103
- if ( sync ) {
104
- connection . reset ( ) ;
105
- } else {
106
- connection . resetAsync ( ) ;
107
- }
100
+ connection . reset ( ) ;
108
101
connection . sync ( ) ;
109
102
connection . _release ( ) ;
110
103
}
Original file line number Diff line number Diff line change @@ -315,8 +315,8 @@ class Connection {
315
315
}
316
316
317
317
/** Queue a RESET-message to be sent to the database. Mutes failure handling. */
318
- resetAsync ( observer ) {
319
- log ( "C" , "RESET_ASYNC" ) ;
318
+ reset ( observer ) {
319
+ log ( 'C' , 'RESET' ) ;
320
320
this . _isHandlingFailure = true ;
321
321
let self = this ;
322
322
let wrappedObs = {
@@ -330,14 +330,6 @@ class Connection {
330
330
}
331
331
} ;
332
332
this . _queueObserver ( wrappedObs ) ;
333
- this . _packer . packStruct ( RESET , [ ] , ( err ) => this . _handleFatalError ( err ) ) ;
334
- this . _chunker . messageBoundary ( ) ;
335
- }
336
-
337
- /** Queue a RESET-message to be sent to the database */
338
- reset ( observer ) {
339
- log ( 'C' , 'RESET' ) ;
340
- this . _queueObserver ( observer ) ;
341
333
this . _packer . packStruct ( RESET , [ ] , ( err ) => this . _handleFatalError ( err ) ) ;
342
334
this . _chunker . messageBoundary ( ) ;
343
335
}
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ describe('ConnectionHolder', () => {
168
168
connectionHolder . initializeConnection ( ) ;
169
169
170
170
connectionHolder . close ( ) . then ( ( ) => {
171
- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
171
+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
172
172
done ( ) ;
173
173
} ) ;
174
174
} ) ;
@@ -201,11 +201,11 @@ describe('ConnectionHolder', () => {
201
201
connectionHolder . initializeConnection ( ) ;
202
202
203
203
connectionHolder . close ( ) . then ( ( ) => {
204
- expect ( connection1 . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
204
+ expect ( connection1 . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
205
205
206
206
connectionHolder . initializeConnection ( ) ;
207
207
connectionHolder . close ( ) . then ( ( ) => {
208
- expect ( connection2 . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
208
+ expect ( connection2 . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
209
209
done ( ) ;
210
210
} ) ;
211
211
} ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ export default class FakeConnection {
31
31
this . creationTimestamp = Date . now ( ) ;
32
32
33
33
this . resetInvoked = 0 ;
34
- this . resetAsyncInvoked = 0 ;
35
34
this . syncInvoked = 0 ;
36
35
this . releaseInvoked = 0 ;
37
36
this . initializationInvoked = 0 ;
@@ -54,10 +53,6 @@ export default class FakeConnection {
54
53
this . resetInvoked ++ ;
55
54
}
56
55
57
- resetAsync ( ) {
58
- this . resetAsyncInvoked ++ ;
59
- }
60
-
61
56
sync ( ) {
62
57
this . syncInvoked ++ ;
63
58
}
@@ -75,17 +70,6 @@ export default class FakeConnection {
75
70
return this . _open ;
76
71
}
77
72
78
- isReleasedOnceOnSessionClose ( ) {
79
- return this . isReleasedOnSessionCloseTimes ( 1 ) ;
80
- }
81
-
82
- isReleasedOnSessionCloseTimes ( times ) {
83
- return this . resetAsyncInvoked === times &&
84
- this . resetInvoked === 0 &&
85
- this . syncInvoked === times &&
86
- this . releaseInvoked === times ;
87
- }
88
-
89
73
isNeverReleased ( ) {
90
74
return this . isReleasedTimes ( 0 ) ;
91
75
}
@@ -95,8 +79,7 @@ export default class FakeConnection {
95
79
}
96
80
97
81
isReleasedTimes ( times ) {
98
- return this . resetAsyncInvoked === 0 &&
99
- this . resetInvoked === times &&
82
+ return this . resetInvoked === times &&
100
83
this . syncInvoked === times &&
101
84
this . releaseInvoked === times ;
102
85
}
Original file line number Diff line number Diff line change @@ -77,13 +77,13 @@ describe('session', () => {
77
77
const session = newSessionWithConnection ( connection ) ;
78
78
79
79
session . close ( ( ) => {
80
- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
80
+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
81
81
82
82
session . close ( ( ) => {
83
- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
83
+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
84
84
85
85
session . close ( ( ) => {
86
- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
86
+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
87
87
done ( ) ;
88
88
} ) ;
89
89
} ) ;
You can’t perform that action at this time.
0 commit comments