@@ -90,7 +90,7 @@ module.exports = async (db, dataList) => {
9090 const client = await db . pool . connect ( ) ;
9191
9292 try {
93- await client . query ( 'BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED' ) ;
93+ // await client.query('BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED');
9494
9595 if ( ! data . metadata . upsertConflictField ) await db . pool . query ( `TRUNCATE ${ data . metadata . table } ` ) ;
9696
@@ -149,19 +149,19 @@ module.exports = async (db, dataList) => {
149149 processedList [ fundListURL ] = etag ;
150150
151151 storeOrLoadProcessedList ( processedList ) ;
152-
153- console . log ( 'commitando' )
154- await client . query ( 'COMMIT' ) ;
155- console . log ( 'commitado' )
152+
153+ //await client.query('COMMIT');
156154 } else {
157155 throw new Error ( `\nUnable to download url ${ data . url } after ${ CONFIG . downloadRetries } retries` ) ;
158156 }
159157 } finally {
160158 await fs . unlink ( localFilename ) ;
161159 }
162160 } catch ( ex ) {
163- await client . query ( 'ROLLBACK' ) ;
164161 console . error ( ex . stack ) ;
162+ // if (!isConnectivityError(e)) {
163+ // await client.query('ROLLBACK');
164+ // }
165165 throw ex ;
166166 } finally {
167167 client . release ( ) ;
@@ -180,3 +180,14 @@ module.exports = async (db, dataList) => {
180180 ui . stop ( 'total' ) ;
181181 ui . close ( ) ;
182182} ;
183+
184+ function isConnectivityError ( err ) {
185+ const code = err && typeof err . code === 'string' && err . code ;
186+ const cls = code && code . substr ( 0 , 2 ) ; // Error Class
187+ return code === 'ECONNRESET' || cls === '08' || cls === '57' ;
188+ // Code 'ECONNRESET' - Connectivity issue handled by the driver.
189+ // Class 08 - Connection Exception.
190+ // Class 57 - Operator Intervention.
191+ //
192+ // ERROR CODES: https://www.postgresql.org/docs/9.6/static/errcodes-appendix.html
193+ }
0 commit comments