MXS-1690: Need Backpressure mechanism (#169)
* implication of backpressure * fix typo and refactor * misc refactor * misc fix * add function session_unlink_backend_dcb and more comments * misc fix * refactor, move all throttling logic into dcb.cc * misc fix * misc fix
This commit is contained in:
@ -168,6 +168,8 @@ extern const char CN_USER[];
|
||||
extern const char CN_USERS[];
|
||||
extern const char CN_VERSION_STRING[];
|
||||
extern const char CN_WEIGHTBY[];
|
||||
extern const char CN_WRITEQ_HIGH_WATER[];
|
||||
extern const char CN_WRITEQ_LOW_WATER[];
|
||||
|
||||
/**
|
||||
* The config parameter
|
||||
@ -233,6 +235,8 @@ typedef struct
|
||||
bool substitute_variables; /**< Should environment variables be substituted */
|
||||
char* local_address; /**< Local address to use when connecting */
|
||||
time_t users_refresh_time; /**< How often the users can be refreshed */
|
||||
uint32_t writeq_high_water; /**< High water mark of dcb write queue */
|
||||
uint32_t writeq_low_water; /**< Low water mark of dcb write queue */
|
||||
} MXS_CONFIG;
|
||||
|
||||
/**
|
||||
@ -503,4 +507,18 @@ bool config_reload(void);
|
||||
*/
|
||||
json_t* config_maxscale_to_json(const char* host);
|
||||
|
||||
/**
|
||||
* @brief Get DCB write queue high water mark
|
||||
*
|
||||
* @return Number of high water mark in bytes
|
||||
*/
|
||||
uint32_t config_writeq_high_water();
|
||||
|
||||
/**
|
||||
* @brief Get DCB write queue low water mark
|
||||
*
|
||||
* @return @return Number of low water mark in bytes
|
||||
*/
|
||||
uint32_t config_writeq_low_water();
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -151,7 +151,9 @@ typedef struct dcb
|
||||
struct servlistener *listener; /**< For a client DCB, the listener data */
|
||||
MXS_PROTOCOL func; /**< The protocol functions for this descriptor */
|
||||
MXS_AUTHENTICATOR authfunc; /**< The authenticator functions for this descriptor */
|
||||
int writeqlen; /**< Current number of byes in the write queue */
|
||||
uint32_t writeqlen; /**< Current number of byes in the write queue */
|
||||
uint32_t high_water; /**< High water mark of write queue */
|
||||
uint32_t low_water; /**< Low water mark of write queue */
|
||||
GWBUF *writeq; /**< Write Data Queue */
|
||||
GWBUF *delayq; /**< Delay Backend Write Data Queue */
|
||||
GWBUF *readq; /**< Read queue for storing incomplete reads */
|
||||
@ -176,6 +178,7 @@ typedef struct dcb
|
||||
bool ssl_write_want_read; /*< Flag */
|
||||
bool ssl_write_want_write; /*< Flag */
|
||||
bool was_persistent; /**< Whether this DCB was in the persistent pool */
|
||||
bool high_water_reached; /** High water mark reached, to determine whether need release throttle */
|
||||
struct
|
||||
{
|
||||
struct dcb *next; /**< Next DCB in owning thread's list */
|
||||
@ -206,7 +209,7 @@ typedef enum
|
||||
#define DCB_SET_HIGH_WATER(x, hi) (x)->low_water = (hi);
|
||||
#define DCB_BELOW_LOW_WATER(x) ((x)->low_water && (x)->writeqlen < (x)->low_water)
|
||||
#define DCB_ABOVE_HIGH_WATER(x) ((x)->high_water && (x)->writeqlen > (x)->high_water)
|
||||
|
||||
#define DCB_THROTTLING_ENABLED(x) ((x)->high_water && (x)->low_water)
|
||||
/**
|
||||
* @brief DCB system initialization function
|
||||
*
|
||||
|
@ -136,6 +136,7 @@ typedef struct session
|
||||
mxs_session_state_t state; /*< Current descriptor state */
|
||||
uint64_t ses_id; /*< Unique session identifier */
|
||||
struct dcb *client_dcb; /*< The client connection */
|
||||
|
||||
struct mxs_router_session *router_session; /*< The router instance data */
|
||||
MXS_SESSION_STATS stats; /*< Session statistics */
|
||||
struct service *service; /*< The service this session is using */
|
||||
|
Reference in New Issue
Block a user