From 10e74225c04fadaa576460abf5401a7d9775d9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 9 Feb 2017 16:53:55 +0200 Subject: [PATCH] Add missing error detection If the file fails to seek to the correct position, the indexing should stop. --- server/modules/routing/avro/avro_index.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/server/modules/routing/avro/avro_index.c b/server/modules/routing/avro/avro_index.c index 905c712c4..d5ede4944 100644 --- a/server/modules/routing/avro/avro_index.c +++ b/server/modules/routing/avro/avro_index.c @@ -87,18 +87,22 @@ void avro_index_file(AVRO_INSTANCE *router, const char* filename) snprintf(sql, sizeof(sql), "SELECT position FROM "INDEX_TABLE_NAME " WHERE filename=\"%s\";", name); + if (sqlite3_exec(router->sqlite_handle, sql, index_query_cb, &pos, &errmsg) != SQLITE_OK) { MXS_ERROR("Failed to read last indexed position of file '%s': %s", name, errmsg); + sqlite3_free(errmsg); + maxavro_file_close(file); + return; } - else if (pos > 0) + + /** Continue from last position */ + if (pos > 0 && !maxavro_record_set_pos(file, pos)) { - /** Continue from last position */ - maxavro_record_set_pos(file, pos); + maxavro_file_close(file); + return; } - sqlite3_free(errmsg); - errmsg = NULL; gtid_pos_t prev_gtid = {0, 0, 0, 0, 0};