@@ -437,14 +437,16 @@ void PostgreSQL::initializeNetworks(PGconn *conn)
437
437
438
438
PQclear (res);
439
439
440
- if (_rc && _rc->clusterMode ) {
441
- auto tx = _cluster->transaction (_myAddressStr, true );
442
- tx.sadd (setKey, networkSet.begin (), networkSet.end ());
443
- tx.exec ();
444
- } else if (_rc && !_rc->clusterMode ) {
445
- auto tx = _redis->transaction (true );
446
- tx.sadd (setKey, networkSet.begin (), networkSet.end ());
447
- tx.exec ();
440
+ if (!networkSet.empty ()) {
441
+ if (_rc && _rc->clusterMode ) {
442
+ auto tx = _cluster->transaction (_myAddressStr, true );
443
+ tx.sadd (setKey, networkSet.begin (), networkSet.end ());
444
+ tx.exec ();
445
+ } else if (_rc && !_rc->clusterMode ) {
446
+ auto tx = _redis->transaction (true );
447
+ tx.sadd (setKey, networkSet.begin (), networkSet.end ());
448
+ tx.exec ();
449
+ }
448
450
}
449
451
450
452
if (++this ->_ready == 2 ) {
@@ -643,19 +645,21 @@ void PostgreSQL::initializeMembers(PGconn *conn)
643
645
644
646
PQclear (res);
645
647
646
- if (_rc != NULL ) {
647
- if (_rc->clusterMode ) {
648
- auto tx = _cluster->transaction (_myAddressStr, true );
649
- for (auto it : networkMembers) {
650
- tx.sadd (it.first , it.second );
651
- }
652
- tx.exec ();
653
- } else {
654
- auto tx = _redis->transaction (true );
655
- for (auto it : networkMembers) {
656
- tx.sadd (it.first , it.second );
648
+ if (!networkMembers.empty ()) {
649
+ if (_rc != NULL ) {
650
+ if (_rc->clusterMode ) {
651
+ auto tx = _cluster->transaction (_myAddressStr, true );
652
+ for (auto it : networkMembers) {
653
+ tx.sadd (it.first , it.second );
654
+ }
655
+ tx.exec ();
656
+ } else {
657
+ auto tx = _redis->transaction (true );
658
+ for (auto it : networkMembers) {
659
+ tx.sadd (it.first , it.second );
660
+ }
661
+ tx.exec ();
657
662
}
658
- tx.exec ();
659
663
}
660
664
}
661
665
if (++this ->_ready == 2 ) {
0 commit comments