Skip to content

Commit 58da975

Browse files
committedAug 8, 2018
Make spare connections more explicit
1 parent e0cc66c commit 58da975

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed
 

‎python/core/auto_generated/qgsapplication.sip.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,12 @@ Set a single custom expression variable.
801801

802802
int maxConcurrentConnectionsPerPool() const;
803803
%Docstring
804-
The maximum number of concurrent connections per connections pool
804+
The maximum number of concurrent connections per connections pool.
805+
806+
.. note::
807+
808+
QGIS may in some situations allocate more than this amount
809+
of connections to avoid deadlocks.
805810

806811
.. versionadded:: 3.4
807812
%End

‎src/core/qgsapplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#include <cpl_conv.h> // for setting gdal options
8686
#include <sqlite3.h>
8787

88-
#define CONN_POOL_MAX_CONCURRENT_CONNS 6
88+
#define CONN_POOL_MAX_CONCURRENT_CONNS 4
8989

9090
QObject *ABISYM( QgsApplication::mFileOpenEventReceiver );
9191
QStringList ABISYM( QgsApplication::mFileOpenEventList );

‎src/core/qgsapplication.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ class CORE_EXPORT QgsApplication : public QApplication
733733
static void setCustomVariable( const QString &name, const QVariant &value );
734734

735735
/**
736-
* The maximum number of concurrent connections per connections pool
736+
* The maximum number of concurrent connections per connections pool.
737+
*
738+
* \note QGIS may in some situations allocate more than this amount
739+
* of connections to avoid deadlocks.
737740
*
738741
* \since QGIS 3.4
739742
*/

‎src/core/qgsconnectionpool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232

3333
#define CONN_POOL_EXPIRATION_TIME 60 // in seconds
34+
#define CONN_POOL_SPARE_CONNECTIONS 2 // number of spare connections in case all the base connections are used but we have a nested request with the risk of a deadlock
3435

3536

3637
/**
@@ -67,7 +68,7 @@ class QgsConnectionPoolGroup
6768

6869
QgsConnectionPoolGroup( const QString &ci )
6970
: connInfo( ci )
70-
, sem( QgsApplication::instance()->maxConcurrentConnectionsPerPool() )
71+
, sem( QgsApplication::instance()->maxConcurrentConnectionsPerPool() + CONN_POOL_SPARE_CONNECTIONS )
7172
{
7273
}
7374

0 commit comments

Comments
 (0)
Please sign in to comment.