andr-sokolov commented on code in PR #1772:
URL: https://github.com/apache/cloudberry/pull/1772#discussion_r3319009694
##########
contrib/interconnect/udp/ic_udpifc.c:
##########
@@ -8224,3 +8315,81 @@ MlPutRxBufferIFC(ChunkTransportState *transportStates,
int motNodeID, int route)
if (param.msg.len != 0)
sendAckWithParam(¶m);
}
+
+Datum
+GpInterconnectGetStatsUDPIFC(PG_FUNCTION_ARGS)
+{
+ /*
+ * Build a tuple descriptor for our result type
+ * The number and type of attributes have to match the definition of the
+ * view gp_interconnect_stats_per_segment
+ */
+#define NUM_IC_STATS_ELEM 17
+ TupleDesc tupdesc = CreateTemplateTupleDesc(NUM_IC_STATS_ELEM);
+
+ TupleDescInitEntry(tupdesc, (AttrNumber) 1, "segid",
+ INT2OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 2, "total_recv_queue_size",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 3, "recv_queue_conting_time",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 4, "total_capacity",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 5, "capacity_counting_time",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 6, "total_buffers",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 7, "buffer_counting_time",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 8, "retransmits",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 9, "startup_cached_pkts",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 10, "mismatches",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 11, "crs_errors",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 12, "snd_pkt_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 13, "recv_pkt_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 14, "disordered_pkt_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 15, "duplicate_pkt_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 16, "recv_ack_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+ TupleDescInitEntry(tupdesc, (AttrNumber) 17, "status_query_msg_num",
+ INT8OID, -1 /* typmod */, 0 /* attdim */);
+
+ tupdesc = BlessTupleDesc(tupdesc);
+
+ Datum values[NUM_IC_STATS_ELEM];
+ bool nulls[NUM_IC_STATS_ELEM];
+ MemSet(nulls, 0, sizeof(nulls));
+
+ LWLockAcquire(ICStatisticsLock, LW_EXCLUSIVE);
Review Comment:
Let's use LW_SHARED instead of LW_EXCLUSIVE because we don't change data. We
should allow multiple sessions to read the structure
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]