MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / _add_parallel_load

Function _add_parallel_load

db/dohsql.c:1126–1153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1124pthread_mutex_t parallel_load_mtx = PTHREAD_MUTEX_INITIALIZER;
1125
1126static int _add_parallel_load(struct sqlclntstate *clnt)
1127{
1128 static int alert_parallel_disabled = 0;
1129 struct thdpool *pool = get_sql_pool(clnt);
1130 int maxt = thdpool_get_maxthds(pool);
1131 int thr_slack = (gbl_dohsql_pool_thr_slack > 0) ? gbl_dohsql_pool_thr_slack : 1;
1132
1133 Pthread_mutex_lock(&parallel_load_mtx);
1134 if ((maxt - thr_slack) <= parallel_load) {
1135 if (!alert_parallel_disabled) {
1136 logmsg(LOGMSG_INFO,
1137 "Sql engine full, switching to non-parallel mode\n");
1138 alert_parallel_disabled = 1;
1139 }
1140 Pthread_mutex_unlock(&parallel_load_mtx);
1141 return SHARD_ERR_LOAD;
1142 } else {
1143 if (alert_parallel_disabled) {
1144 logmsg(LOGMSG_INFO,
1145 "Sql engine load cleared, re-activating parallel mode\n");
1146 alert_parallel_disabled = 0;
1147 }
1148 }
1149 parallel_load++;
1150 Pthread_mutex_unlock(&parallel_load_mtx);
1151
1152 return SHARD_NOERR;
1153}
1154
1155static void _rem_parallel_load(void)
1156{

Callers 1

dohsql_distributeFunction · 0.85

Calls 3

get_sql_poolFunction · 0.85
thdpool_get_maxthdsFunction · 0.85
logmsgFunction · 0.50

Tested by

no test coverage detected