diff --git a/sources/backend.c b/sources/backend.c index bd7236044..3e1ea4725 100644 --- a/sources/backend.c +++ b/sources/backend.c @@ -695,10 +695,13 @@ int od_backend_update_parameter(od_server_t *server, char *context, char *data, } int od_backend_ready_wait(od_server_t *server, char *context, int count, - uint32_t time_ms) + uint32_t time_ms, uint32_t ignore_errors) { od_instance_t *instance = server->global->instance; int ready = 0; + int query_rc; + query_rc = 0; + for (;;) { machine_msg_t *msg; msg = od_read(&server->io, time_ms); @@ -730,17 +733,20 @@ int od_backend_ready_wait(od_server_t *server, char *context, int count, od_backend_error(server, context, machine_msg_data(msg), machine_msg_size(msg)); machine_msg_free(msg); - continue; + if (!ignore_errors) { + query_rc = -1; + } } else if (type == KIWI_BE_READY_FOR_QUERY) { od_backend_ready(server, machine_msg_data(msg), machine_msg_size(msg)); ready++; if (ready == count) { machine_msg_free(msg); - return 0; + return query_rc; } + } else { + machine_msg_free(msg); } - machine_msg_free(msg); } /* never reached */ } @@ -776,13 +782,13 @@ od_retcode_t od_backend_query_send(od_server_t *server, char *context, od_retcode_t od_backend_query(od_server_t *server, char *context, char *query, char *param, int len, uint32_t timeout, - uint32_t count) + uint32_t count, uint32_t ignore_errors) { if (od_backend_query_send(server, context, query, param, len) == NOT_OK_RESPONSE) { return NOT_OK_RESPONSE; } - od_retcode_t rc = - od_backend_ready_wait(server, context, count, timeout); + od_retcode_t rc = od_backend_ready_wait(server, context, count, timeout, + ignore_errors); return rc; } diff --git a/sources/backend.h b/sources/backend.h index f2c1ddd8d..b583a528d 100644 --- a/sources/backend.h +++ b/sources/backend.h @@ -16,11 +16,11 @@ void od_backend_error(od_server_t *, char *, char *, uint32_t); int od_backend_update_parameter(od_server_t *, char *, char *, uint32_t, int); int od_backend_ready(od_server_t *, char *, uint32_t); -int od_backend_ready_wait(od_server_t *, char *, int, uint32_t); +int od_backend_ready_wait(od_server_t *, char *, int, uint32_t, uint32_t); od_retcode_t od_backend_query_send(od_server_t *server, char *context, char *query, char *param, int len); od_retcode_t od_backend_query(od_server_t *, char *, char *, char *, int, - uint32_t, uint32_t); + uint32_t, uint32_t, uint32_t); #endif /* ODYSSEY_BACKEND_H */ diff --git a/sources/reset.c b/sources/reset.c index 757a70107..b29ac3876 100644 --- a/sources/reset.c +++ b/sources/reset.c @@ -75,11 +75,11 @@ int od_reset(od_server_t *server) wait_timeout, wait_try); wait_try++; rc = od_backend_ready_wait(server, "reset", 1, - wait_timeout); - if (rc == -1) + wait_timeout, 1); + if (rc == NOT_OK_RESPONSE) break; } - if (rc == -1) { + if (rc == NOT_OK_RESPONSE) { if (!machine_timedout()) goto error; @@ -104,7 +104,7 @@ int od_reset(od_server_t *server) wait_try_cancel++; rc = od_cancel(server->global, route->rule->storage, &server->key, &server->id); - if (rc == -1) + if (rc == NOT_OK_RESPONSE) goto error; continue; } @@ -119,11 +119,11 @@ int od_reset(od_server_t *server) if (route->rule->pool->rollback) { if (server->is_transaction) { char query_rlb[] = "ROLLBACK"; - rc = od_backend_query(server, "reset-rollback", - query_rlb, NULL, - sizeof(query_rlb), wait_timeout, - 1); - if (rc == -1) + rc = od_backend_query( + server, "reset-rollback", query_rlb, NULL, + sizeof(query_rlb), wait_timeout, 1, + 0 /*ignore server error messages*/); + if (rc == NOT_OK_RESPONSE) goto error; assert(!server->is_transaction); } @@ -134,7 +134,7 @@ int od_reset(od_server_t *server) char query_discard[] = "DISCARD ALL"; rc = od_backend_query(server, "reset-discard", query_discard, NULL, sizeof(query_discard), wait_timeout, - 1); + 1, 0 /*ignore server error messages*/); if (rc == NOT_OK_RESPONSE) goto error; } @@ -146,16 +146,17 @@ int od_reset(od_server_t *server) "SET SESSION AUTHORIZATION DEFAULT;RESET ALL;CLOSE ALL;UNLISTEN *;SELECT pg_advisory_unlock_all();DISCARD PLANS;DISCARD SEQUENCES;DISCARD TEMP;"; rc = od_backend_query(server, "reset-discard-smart", query_discard, NULL, - sizeof(query_discard), wait_timeout, 1); + sizeof(query_discard), wait_timeout, 1, + 0 /*ignore server error messages*/); if (rc == NOT_OK_RESPONSE) goto error; } if (route->rule->pool->discard_query != NULL) { - rc = od_backend_query(server, "reset-discard-smart-string", - route->rule->pool->discard_query, NULL, - strlen(route->rule->pool->discard_query) + - 1, - wait_timeout, 1); + rc = od_backend_query( + server, "reset-discard-smart-string", + route->rule->pool->discard_query, NULL, + strlen(route->rule->pool->discard_query) + 1, + wait_timeout, 1, 0 /*ignore server error messages*/); if (rc == NOT_OK_RESPONSE) goto error; }