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

Function handle_sql_commitrollback

db/sqlinterfaces.c:2231–2421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2229}
2230
2231int handle_sql_commitrollback(struct sqlthdstate *thd,
2232 struct sqlclntstate *clnt,
2233 enum trans_clntcomm sideeffects)
2234{
2235 int rc = 0;
2236 int outrc = 0;
2237
2238 if (sideeffects == TRANS_CLNTCOMM_NORMAL) {
2239 /* Don't setup(reset) logger for commits of individual chunks,
2240 and for the implicit commit from an SP */
2241 reqlog_setup_begin_commit_rollback(thd, clnt);
2242 }
2243
2244 int64_t rows = clnt->log_effects.num_updated +
2245 clnt->log_effects.num_deleted +
2246 clnt->log_effects.num_inserted;
2247
2248 reqlog_set_cost(thd->logger, 0);
2249 reqlog_set_rows(thd->logger, rows);
2250
2251 if (rows > 0 && gbl_forbid_incoherent_writes && !clnt->had_lease_at_begin) {
2252 abort_dbtran(clnt);
2253 errstat_cat_str(&clnt->osql.xerr, "failed write from incoherent node");
2254 clnt->osql.xerr.errval = ERR_BLOCK_FAILED + ERR_VERIFY;
2255 sql_set_sqlengine_state(clnt, __FILE__, __LINE__,
2256 SQLENG_NORMAL_PROCESS);
2257 outrc = CDB2ERR_VERIFY_ERROR;
2258 Pthread_mutex_lock(&clnt->wait_mutex);
2259 clnt->ready_for_heartbeats = 0;
2260 Pthread_mutex_unlock(&clnt->wait_mutex);
2261 if (do_send_commitrollback_response(clnt, sideeffects)) {
2262 write_response(clnt, RESPONSE_ERROR, clnt->osql.xerr.errstr, outrc);
2263 }
2264 goto done;
2265 }
2266
2267 rc = do_commitrollback(thd, clnt, sideeffects);
2268
2269 clnt->ins_keys = 0ULL;
2270 clnt->del_keys = 0ULL;
2271
2272 if (clnt->arr) {
2273 currangearr_free(clnt->arr);
2274 clnt->arr = NULL;
2275 }
2276 if (clnt->selectv_arr) {
2277 currangearr_free(clnt->selectv_arr);
2278 clnt->selectv_arr = NULL;
2279 }
2280
2281 destroy_hash(clnt->ddl_tables, free_it);
2282 destroy_hash(clnt->dml_tables, free_it);
2283 clnt->ddl_tables = NULL;
2284 clnt->dml_tables = NULL;
2285 destroy_hash(clnt->ddl_contexts, free_clnt_ddl_context);
2286 clnt->ddl_contexts = NULL;
2287
2288 /* reset the state after send_done; we use ctrl_sqlengine to know

Callers 4

chunk_transactionFunction · 0.85
db_commit_intFunction · 0.85
db_rollback_intFunction · 0.85

Calls 15

reqlog_set_costFunction · 0.85
reqlog_set_rowsFunction · 0.85
abort_dbtranFunction · 0.85
errstat_cat_strFunction · 0.85
sql_set_sqlengine_stateFunction · 0.85
write_responseFunction · 0.85
do_commitrollbackFunction · 0.85
currangearr_freeFunction · 0.85
destroy_hashFunction · 0.85
osql_set_replayFunction · 0.85

Tested by

no test coverage detected