Ok, here is the fixed patch. It still use PRIMARY_NODE_ID to check if a
node is primary because IS_MASTER_NODE_ID() always return node 0 as
primary (even in load balance mode). Maybe this macro should be renamed
DEFAULT_MASTER_NODE_ID() as this is what it is doing but this is not
really important.


Le 05/01/2011 22:19, Guillaume Lelarge a écrit :
> Le 05/01/2011 11:25, Gilles Darold a écrit :
>> Le 05/01/2011 09:04, Guillaume Lelarge a écrit :
>>> Le 05/01/2011 02:46, Tatsuo Ishii a écrit :
>>>>> Le 30/12/2010 23:52, Gilles Darold a écrit :
>>>>>> Sorry again I've sent the wrong patch, here is the one using
>>>>>> REAL_PRIMARY_NODE_ID.
>>>>>> Please apologies for so much post.
>>>>>>
>>>>> It compiles and runs. No bug found.
>>>> I wonder what is shown in the field when operated in other than
>>>> master/slave & streaming replication mode.
>>> It says that all nodes are primary or all nodes are standby, which
>>> obvisouly is wrong. The patch needs to check we are in master/slave mode
>>> and in replication mode. Otherwise, it should say N/A. Gilles, ca, you
>>> do this little change, please?
>>>
>> Well in any case it display the master slave state, that mean that if we
>> are not in master slave node 0 is always P and others are S. Will fix
>> that as you want, here what I propose :
>>
>> - In replication mode state is "R" for every node.
>> - In master/slave mode we still have both "P" for the primary and "S"
>> for secondaries.
>> - In non master/slave mode nor replication mode all node states are set
>> to "-"
>>
>> I will used "IS_MASTER_NODE_ID(i)" instead of "PRIMARY_NODE_ID == i" to
>> test the primary node.
>>
>> Is that ok for you ?
>>
> Yeah, that's fine.
>
>


-- 
Gilles Darold
http://dalibo.com - http://dalibo.org

--- pgpool-II/pool_process_reporting.c	2010-12-30 01:47:05.000000000 +0100
+++ pgpool-II-current/pool_process_reporting.c	2011-01-06 09:03:13.000000000 +0100
@@ -55,6 +55,7 @@
 	char port[POOLCONFIG_MAXIDENTLEN+1];
 	char status[POOLCONFIG_MAXSTATLEN+1];
 	char lb_weight[POOLCONFIG_MAXWEIGHTLEN+1];
+        char state[POOLCONFIG_MAXSTATLEN+1];
 } POOL_REPORT_NODES;
 
 /* processes report struct */
@@ -662,8 +663,8 @@
 void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
 {
 	static char *cursorname = "blank";
-	static short num_fields = 5;
-	static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight"};
+	static short num_fields = 6;
+	static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight", "state"};
 	static int oid = 0;
 	static short fsize = -1;
 	static int mod = 0;
@@ -692,6 +693,21 @@
 	    snprintf(nodes[i].port, 	POOLCONFIG_MAXIDENTLEN, "%d", 	bi->backend_port);
 	    snprintf(nodes[i].status, 	POOLCONFIG_MAXSTATLEN, 	"%d", 	bi->backend_status);
 	    snprintf(nodes[i].lb_weight, POOLCONFIG_MAXWEIGHTLEN, "%f", bi->backend_weight/RAND_MAX);
+	    if (MASTER_SLAVE)
+	    {
+		if (PRIMARY_NODE_ID == i)
+			snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s",   "P");
+		else
+			snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s",   "S");
+	    }
+	    else if (REPLICATION)
+	    {
+		snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s",   "R");
+	    }
+	    else
+	    {
+		snprintf(nodes[i].state, POOLCONFIG_MAXSTATLEN, "%s",   "-");
+	    }
 	}
 
 	nrows = i;
@@ -787,6 +803,11 @@
 			hsize = htonl(size+4);
 			pool_write(frontend, &hsize, sizeof(hsize));
 			pool_write(frontend, nodes[i].lb_weight, size);
+
+			size = strlen(nodes[i].state);
+			hsize = htonl(size+4);
+			pool_write(frontend, &hsize, sizeof(hsize));
+			pool_write(frontend, nodes[i].state, size);
 		}
 	}
 	else
@@ -801,6 +822,7 @@
 			len += sizeof(int) + strlen(nodes[i].port);
 			len += sizeof(int) + strlen(nodes[i].status);
 			len += sizeof(int) + strlen(nodes[i].lb_weight);
+			len += sizeof(int) + strlen(nodes[i].state);
 			len = htonl(len);
 			pool_write(frontend, &len, sizeof(len));
 			s = htons(num_fields);
@@ -825,6 +847,10 @@
 			len = htonl(strlen(nodes[i].lb_weight));
 			pool_write(frontend, &len, sizeof(len));
 			pool_write(frontend, nodes[i].lb_weight, strlen(nodes[i].lb_weight));
+
+			len = htonl(strlen(nodes[i].state));
+			pool_write(frontend, &len, sizeof(len));
+			pool_write(frontend, nodes[i].state, strlen(nodes[i].state));
 		}
 	}
 
_______________________________________________
Pgpool-hackers mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-hackers

Reply via email to