Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-08-01 14:45:31+10:00, pekka@stripped +9 -0
[PATCH] SendBuffer throttle
If any affected tcp SendBuffer is over 80% full,
return temporary error 1218 from LQH.
Index: telco-6.1/storage/ndb/include/transporter/TransporterRegistry.hpp
===================================================================
storage/ndb/include/transporter/TransporterRegistry.hpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +27 -0
SendBuffer throttle
storage/ndb/src/common/transporter/TCP_Transporter.cpp@stripped, 2007-08-01 11:55:49+10:00,
pekka@stripped +4 -0
SendBuffer throttle
storage/ndb/src/common/transporter/TCP_Transporter.hpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +15 -0
SendBuffer throttle
storage/ndb/src/common/transporter/Transporter.hpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +4 -0
SendBuffer throttle
storage/ndb/src/kernel/blocks/ERROR_codes.txt@stripped, 2007-08-01 12:02:11+10:00,
pekka@stripped +3 -1
SendBuffer throttle
storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +4 -0
SendBuffer throttle
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +42 -0
SendBuffer throttle
storage/ndb/src/kernel/blocks/suma/Suma.hpp@stripped, 2007-08-01 11:48:37+10:00,
pekka@stripped +3 -0
SendBuffer throttle
storage/ndb/src/ndbapi/ndberror.c@stripped, 2007-08-01 11:48:37+10:00, pekka@stripped +1 -0
SendBuffer throttle
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: pekka
# Host: willster.(none)
# Root: /home/stewart/Documents/MySQL/5.1/telco-6.1.17
--- 1.25/storage/ndb/include/transporter/TransporterRegistry.hpp 2006-12-24 06:20:08
+11:00
+++ 1.26/storage/ndb/include/transporter/TransporterRegistry.hpp 2007-08-01 11:48:37
+10:00
@@ -35,6 +35,8 @@
#include <mgmapi/mgmapi.h>
+#include <NodeBitmask.hpp>
+
// A transporter is always in an IOState.
// NoHalt is used initially and as long as it is no restrictions on
// sending or receiving.
@@ -206,6 +208,13 @@
* Get #free bytes in send buffer for <em>node</node>
*/
Uint32 get_free_buffer(Uint32 node) const ;
+
+ /**
+ * Set or clear overloaded bit.
+ * Query if any overloaded bit is set.
+ */
+ void set_status_overloaded(Uint32 nodeId, bool val);
+ const NodeBitmask& get_status_overloaded() const;
/**
* prepareSend
@@ -303,6 +312,11 @@
*/
PerformState* performStates;
IOState* ioStates;
+
+ /**
+ * Overloaded bits, for fast check.
+ */
+ NodeBitmask m_status_overloaded;
/**
* Unpack signal data
@@ -338,5 +352,18 @@
int m_shm_own_pid;
int m_transp_count;
};
+
+inline void
+TransporterRegistry::set_status_overloaded(Uint32 nodeId, bool val)
+{
+ assert(nodeId < MAX_NODES);
+ m_status_overloaded.set(nodeId, val);
+}
+
+inline const NodeBitmask&
+TransporterRegistry::get_status_overloaded() const
+{
+ return m_status_overloaded;
+}
#endif // Define of TransporterRegistry_H
--- 1.14/storage/ndb/src/common/transporter/TCP_Transporter.cpp 2006-12-24 06:20:12 +11:00
+++ 1.15/storage/ndb/src/common/transporter/TCP_Transporter.cpp 2007-08-01 11:55:49 +10:00
@@ -89,6 +89,8 @@
sockOptSndBufSize = 71540;
sockOptNodelay = 1;
sockOptTcpMaxSeg = 4096;
+
+ overloadedPct = 80; // make configurable in next patch
}
TCP_Transporter::~TCP_Transporter() {
@@ -273,6 +275,7 @@
void
TCP_Transporter::updateWritePtr(Uint32 lenBytes, Uint32 prio){
m_sendBuffer.updateInsertPtr(lenBytes);
+ update_status_overloaded();
const int bufsize = m_sendBuffer.bufferSize();
if(bufsize > TCP_SEND_LIMIT) {
@@ -317,6 +320,7 @@
if (nBytesSent > 0) {
m_sendBuffer.bytesSent(nBytesSent);
+ update_status_overloaded();
sendCount ++;
sendSize += nBytesSent;
--- 1.10/storage/ndb/src/common/transporter/TCP_Transporter.hpp 2007-05-31 01:28:35 +10:00
+++ 1.11/storage/ndb/src/common/transporter/TCP_Transporter.hpp 2007-08-01 11:48:37 +10:00
@@ -156,6 +156,12 @@
Uint64 sendSize;
ReceiveBuffer receiveBuffer;
+
+ /**
+ * SendBuffer throttle.
+ */
+ Uint32 overloadedPct;
+ void update_status_overloaded();
};
inline
@@ -185,6 +191,15 @@
bool
TCP_Transporter::hasDataToSend() const {
return m_sendBuffer.dataSize > 0;
+}
+
+inline
+void
+TCP_Transporter::update_status_overloaded() {
+ const Uint32 used = m_sendBuffer.dataSize;
+ const Uint32 total = m_sendBuffer.sizeOfBuffer;
+ const bool val = (100 * used > overloadedPct * total);
+ set_status_overloaded(val);
}
inline
--- 1.16/storage/ndb/src/common/transporter/Transporter.hpp 2006-12-24 06:20:13 +11:00
+++ 1.17/storage/ndb/src/common/transporter/Transporter.hpp 2007-08-01 11:48:37 +10:00
@@ -86,6 +86,10 @@
};
virtual Uint32 get_free_buffer() const = 0;
+
+ void set_status_overloaded(bool val) {
+ m_transporter_registry.set_status_overloaded(remoteNodeId, val);
+ }
protected:
Transporter(TransporterRegistry &,
--- 1.39/storage/ndb/src/kernel/blocks/ERROR_codes.txt 2007-06-26 23:39:33 +10:00
+++ 1.40/storage/ndb/src/kernel/blocks/ERROR_codes.txt 2007-08-01 12:02:11 +10:00
@@ -3,7 +3,7 @@
Next NDBFS 2000
Next DBACC 3002
Next DBTUP 4029
-Next DBLQH 5045
+Next DBLQH 5048
Next DBDICT 6007
Next DBDIH 7186
Next DBTC 8040
@@ -224,6 +224,8 @@
5100,5101: Drop ABORT req in primary replica
Crash on "next" ABORT
+
+5047: ZTRANSPORTER_OVERLOADED_ERROR in execLQHKEYREQ
ERROR CODES FOR TESTING TIME-OUT HANDLING IN DBTC
-------------------------------------------------
--- 1.65/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp 2007-06-25 15:40:38 +10:00
+++ 1.66/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp 2007-08-01 11:48:37 +10:00
@@ -292,6 +292,7 @@
#define ZTOO_MANY_COPY_ACTIVE_ERROR 1208 // COPY_FRAG and COPY_ACTIVEREF code
#define ZCOPY_ACTIVE_ERROR 1210 // COPY_ACTIVEREF error code
#define ZNO_TC_CONNECT_ERROR 1217 // Simple Read + SCAN
+#define ZTRANSPORTER_OVERLOADED_ERROR 1218
/* ------------------------------------------------------------------------- */
/* ERROR CODES ADDED IN VERSION 1.X */
/* ------------------------------------------------------------------------- */
@@ -2416,6 +2417,9 @@
void aiStateErrorCheckLab(Signal* signal, Uint32* dataPtr, Uint32 length);
void takeOverErrorLab(Signal* signal);
void endgettupkeyLab(Signal* signal);
+ bool checkTransporterOverloaded(Signal* signal,
+ const NodeBitmask& all,
+ const class LqhKeyReq* req);
void noFreeRecordLab(Signal* signal,
const class LqhKeyReq * lqhKeyReq,
Uint32 errorCode);
--- 1.155/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2007-07-05 06:41:36 +10:00
+++ 1.156/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp 2007-08-01 11:48:37 +10:00
@@ -64,6 +64,8 @@
#include <signaldata/RouteOrd.hpp>
#include <signaldata/FsRef.hpp>
+#include "../suma/Suma.hpp"
+
// Use DEBUG to print messages that should be
// seen only when we debug the product
#ifdef VM_TRACE
@@ -3356,6 +3358,35 @@
databufptr = regDatabufptr;
}//Dblqh::seizeTupkeybuf()
+bool Dblqh::checkTransporterOverloaded(Signal* signal,
+ const NodeBitmask& all,
+ const LqhKeyReq* req)
+{
+ // nodes likely to be affected by this op
+ NodeBitmask mask;
+ // tc
+ Uint32 tc_node = refToNode(req->tcBlockref);
+ if (tc_node < MAX_NODES) // not worth to crash here
+ mask.set(tc_node);
+ const Uint8 op = LqhKeyReq::getOperation(req->requestInfo);
+ if (op == ZREAD || op == ZREAD_EX) {
+ // the receiver
+ Uint32 api_node = refToNode(req->variableData[0]);
+ if (api_node < MAX_NODES) // not worth to crash here
+ mask.set(api_node);
+ } else {
+ // next replica
+ Uint32 replica_node = LqhKeyReq::getNextReplicaNodeId(req->fragmentData);
+ if (replica_node < MAX_NODES) // could be ZNIL
+ mask.set(replica_node);
+ // event subscribers
+ const Suma* suma = (Suma*)globalData.getBlock(SUMA);
+ mask.bitOR(suma->getSubscriberNodes());
+ }
+ mask.bitAND(all);
+ return !mask.isclear();
+}
+
/* ------------------------------------------------------------------------- */
/* ------- TAKE CARE OF LQHKEYREQ ------- */
/* LQHKEYREQ IS THE SIGNAL THAT STARTS ALL OPERATIONS IN THE LQH BLOCK */
@@ -3368,6 +3399,17 @@
Uint8 tfragDistKey;
const LqhKeyReq * const lqhKeyReq = (LqhKeyReq *)signal->getDataPtr();
+
+ {
+ const NodeBitmask& all = globalTransporterRegistry.get_status_overloaded();
+ if (unlikely(!all.isclear()) &&
+ checkTransporterOverloaded(signal, all, lqhKeyReq) ||
+ ERROR_INSERTED_CLEAR(5047)) {
+ jam();
+ noFreeRecordLab(signal, lqhKeyReq, ZTRANSPORTER_OVERLOADED_ERROR);
+ return;
+ }
+ }
sig0 = lqhKeyReq->clientConnectPtr;
if (cfirstfreeTcConrec != RNIL && !ERROR_INSERTED(5031)) {
--- 1.20/storage/ndb/src/kernel/blocks/suma/Suma.hpp 2007-01-24 16:20:36 +11:00
+++ 1.21/storage/ndb/src/kernel/blocks/suma/Suma.hpp 2007-08-01 11:48:37 +10:00
@@ -494,6 +494,9 @@
void resetRestart(Signal* signal);
} Restart;
+ // for LQH transporter overload check
+ const NodeBitmask& getSubscriberNodes() const { return c_subscriber_nodes; }
+
private:
friend class Restart;
/**
--- 1.88/storage/ndb/src/ndbapi/ndberror.c 2007-06-04 18:31:05 +10:00
+++ 1.89/storage/ndb/src/ndbapi/ndberror.c 2007-08-01 11:48:37 +10:00
@@ -179,6 +179,7 @@
{ 873, DMEC, TR, "Out of attrinfo records for scan in tuple manager" },
{ 899, DMEC, TR, "Rowid already allocated" },
{ 1217, DMEC, TR, "Out of operation records in local data manager (increase
MaxNoOfLocalOperations)" },
+ { 1218, DMEC, TR, "Send Buffers overloaded in NDB kernel" },
{ 1220, DMEC, TR, "REDO log files overloaded, consult online manual (increase
FragmentLogFileSize)" },
{ 1222, DMEC, TR, "Out of transaction markers in LQH" },
{ 4021, DMEC, TR, "Out of Send Buffer space in NDB API" },
| Thread |
|---|
| • bk commit into 5.1 tree (pekka:1.2579) | Stewart Smith | 1 Aug |