Skip to content

Commit

Permalink
[clusterer] Fix error handling when failing to load nodes
Browse files Browse the repository at this point in the history
On failing to add a node (to the cluster), continue, as time as that node is not the current node.
And if giving up on whole cluster info loading, be sure we clean up and properly report this to the above layer - the last thing we should do is to report success (on load) but have partial, unconsistent data.

Fixes #3473
  • Loading branch information
bogdan-iancu committed Sep 23, 2024
1 parent dac790f commit 784e1a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/clusterer/clusterer_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static int mod_init(void)
LM_ERR("cannot initialize database connection\n");
goto error;
}
if (load_db_info(&dr_dbf, db_hdl, &db_table, cluster_list) < 0) {
if (load_db_info(&dr_dbf, db_hdl, &db_table, cluster_list) != 0) {
LM_ERR("Failed to load info from DB\n");
goto error;
}
Expand Down
12 changes: 9 additions & 3 deletions modules/clusterer/node_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ int load_db_info(db_func_t *dr_dbf, db_con_t* db_hdl, str *db_table,

if (RES_ROW_N(res) == 0) {
LM_WARN("Current node does not belong to any cluster\n");
dr_dbf->free_result(db_hdl, res);
return 1;
}

Expand Down Expand Up @@ -493,12 +494,17 @@ int load_db_info(db_func_t *dr_dbf, db_con_t* db_hdl, str *db_table,
if ((rc = add_node_info(&_, cl_list, int_vals, str_vals)) != 0) {
LM_ERR("Unable to add node info to backing list\n");
if (rc < 0) {
return -1;
/* serious error happened, better give up */
goto error;
} else if (int_vals[INT_VALS_NODE_ID_COL] == current_id) {
LM_ERR("Invalid info for local node\n");
return -1;
/* the node info is bogus, but cannot be skipped
* as it is the current node) */
goto error;
} else {
return 2;
/* the node info is bogus, just skip it
* (it's not current node) */
continue;
}
}
}
Expand Down

0 comments on commit 784e1a4

Please sign in to comment.