17
17
* function that will switch fe/be protocol to a COPY mode and enters endless
18
18
* receiving loop.
19
19
*
20
+ * XXX: needs better PQerror reporting logic -- perhaps once per given Idle
21
+ * connection.
22
+ *
23
+ * XXX: is there max size for a connstr?
20
24
*
21
25
* Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
22
26
* Portions Copyright (c) 1994, Regents of the University of California
@@ -457,6 +461,10 @@ dmq_sender_main(Datum main_arg)
457
461
458
462
/*
459
463
* Generate timeout or socket events.
464
+ *
465
+ *
466
+ * XXX: here we expect that whole cyle takes less then 250-100 ms.
467
+ * Otherwise we can stuck with timer_event forever.
460
468
*/
461
469
now_millisec = dmq_now ();
462
470
if (now_millisec - prev_timer_at > 250 )
@@ -466,7 +474,7 @@ dmq_sender_main(Datum main_arg)
466
474
}
467
475
else
468
476
{
469
- nevents = WaitEventSetWait (set , wait ? 250 : 0 , & event ,
477
+ nevents = WaitEventSetWait (set , wait ? 100 : 0 , & event ,
470
478
1 , PG_WAIT_EXTENSION );
471
479
}
472
480
@@ -506,8 +514,9 @@ dmq_sender_main(Datum main_arg)
506
514
NULL , (void * ) conn_id );
507
515
508
516
mtm_log (DmqStateIntermediate ,
509
- "[DMQ] switching %s from Idle to Connecting" ,
510
- conns [conn_id ].receiver_name );
517
+ "[DMQ] switching %s from Idle to Connecting on '%s'" ,
518
+ conns [conn_id ].receiver_name ,
519
+ conns [conn_id ].connstr );
511
520
}
512
521
}
513
522
/* Heatbeat */
@@ -547,9 +556,24 @@ dmq_sender_main(Datum main_arg)
547
556
{
548
557
PostgresPollingStatusType status = PQconnectPoll (conns [conn_id ].pgconn );
549
558
559
+ mtm_log (DmqStateIntermediate ,
560
+ "[DMQ] Connecting: PostgresPollingStatusType = %d on %s" ,
561
+ status ,
562
+ conns [conn_id ].receiver_name );
563
+
550
564
if (status == PGRES_POLLING_READING )
551
565
{
552
566
ModifyWaitEvent (set , event .pos , WL_SOCKET_READABLE , NULL );
567
+ mtm_log (DmqStateIntermediate ,
568
+ "[DMQ] Connecting: modify wait event to WL_SOCKET_READABLE on %s" ,
569
+ conns [conn_id ].receiver_name );
570
+ }
571
+ else if (status == PGRES_POLLING_WRITING )
572
+ {
573
+ ModifyWaitEvent (set , event .pos , WL_SOCKET_WRITEABLE , NULL );
574
+ mtm_log (DmqStateIntermediate ,
575
+ "[DMQ] Connecting: modify wait event to WL_SOCKET_WRITEABLE on %s" ,
576
+ conns [conn_id ].receiver_name );
553
577
}
554
578
else if (status == PGRES_POLLING_OK )
555
579
{
@@ -577,7 +601,7 @@ dmq_sender_main(Datum main_arg)
577
601
PQerrorMessage (conns [conn_id ].pgconn ));
578
602
}
579
603
else
580
- Assert (status == PGRES_POLLING_WRITING );
604
+ Assert (false );
581
605
582
606
break ;
583
607
}
0 commit comments