From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH v2 6/6] error: move XlogGapError to box/error.h Date: Fri, 29 Jun 2018 19:48:33 +0300 [thread overview] Message-ID: <c6932592681ff29d49880d026e82605a1bdf32da.1530287767.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1530287767.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1530287767.git.vdavydov.dev@gmail.com> All box exceptions belong to box/error.h. Let's move XlogGapError there as well. This will facilitate conversion of recovery.cc to C when we finally get to it. While we are at it, let's also move BuildXlogError function declaration from diag.h to box/error.h, closer to its definition. --- src/box/CMakeLists.txt | 2 +- src/box/error.cc | 36 ++++++++++++++++++++++++++++++++---- src/box/error.h | 16 ++++++++++++++++ src/box/recovery.cc | 21 --------------------- src/diag.h | 2 -- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index 6b1ae3e8..f4899091 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -21,7 +21,7 @@ set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${lua_sources}) include_directories(${ZSTD_INCLUDE_DIRS}) -add_library(box_error STATIC error.cc errcode.c) +add_library(box_error STATIC error.cc errcode.c vclock.c) target_link_libraries(box_error core stat) add_library(vclock STATIC vclock.c) diff --git a/src/box/error.cc b/src/box/error.cc index 6b14dff0..c4f782a4 100644 --- a/src/box/error.cc +++ b/src/box/error.cc @@ -31,8 +31,11 @@ #include "error.h" #include <stdio.h> -#include <fiber.h> -#include <rmean.h> +#include "fiber.h" +#include "rmean.h" +#include "trigger.h" +#include "vclock.h" +#include "schema.h" /* {{{ public API */ @@ -176,8 +179,33 @@ BuildXlogError(const char *file, unsigned line, const char *format, ...) } } -#include "schema.h" -#include "trigger.h" +const struct type_info type_XlogGapError = + make_type("XlogGapError", &type_XlogError); + +XlogGapError::XlogGapError(const char *file, unsigned line, + const struct vclock *from, const struct vclock *to) + : XlogError(&type_XlogGapError, file, line) +{ + char *s_from = vclock_to_string(from); + char *s_to = vclock_to_string(to); + snprintf(errmsg, sizeof(errmsg), + "Missing .xlog file between LSN %lld %s and %lld %s", + (long long) vclock_sum(from), s_from ? s_from : "", + (long long) vclock_sum(to), s_to ? s_to : ""); + free(s_from); + free(s_to); +} + +struct error * +BuildXlogGapError(const char *file, unsigned line, + const struct vclock *from, const struct vclock *to) +{ + try { + return new XlogGapError(file, line, from, to); + } catch (OutOfMemory *e) { + return e; + } +} struct rlist on_access_denied = RLIST_HEAD_INITIALIZER(on_access_denied); diff --git a/src/box/error.h b/src/box/error.h index c791e6c6..b8c7cf73 100644 --- a/src/box/error.h +++ b/src/box/error.h @@ -36,6 +36,8 @@ extern "C" { #endif /* defined(__cplusplus) */ +struct vclock; + struct error * BuildClientError(const char *file, unsigned line, uint32_t errcode, ...); @@ -44,6 +46,12 @@ BuildAccessDeniedError(const char *file, unsigned int line, const char *access_type, const char *object_type, const char *object_name, const char *user_name); +struct error * +BuildXlogError(const char *file, unsigned line, const char *format, ...); + +struct error * +BuildXlogGapError(const char *file, unsigned line, + const struct vclock *from, const struct vclock *to); /** \cond public */ @@ -250,6 +258,14 @@ struct XlogError: public Exception virtual void raise() { throw this; } }; +struct XlogGapError: public XlogError +{ + XlogGapError(const char *file, unsigned line, + const struct vclock *from, const struct vclock *to); + + virtual void raise() { throw this; } +}; + #endif /* defined(__cplusplus) */ #endif /* TARANTOOL_BOX_ERROR_H_INCLUDED */ diff --git a/src/box/recovery.cc b/src/box/recovery.cc index 722b86c5..c007b1fa 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -74,27 +74,6 @@ * IRR -> RR # recovery_follow_local() */ -const struct type_info type_XlogGapError = - make_type("XlogGapError", &type_XlogError); - -struct XlogGapError: public XlogError { - /** Used by BuildXlogGapError() */ - XlogGapError(const char *file, unsigned line, - const struct vclock *from, const struct vclock *to) - :XlogError(&type_XlogGapError, file, line) - { - char *s_from = vclock_to_string(from); - char *s_to = vclock_to_string(to); - snprintf(errmsg, sizeof(errmsg), - "Missing .xlog file between LSN %lld %s and %lld %s", - (long long) vclock_sum(from), s_from ? s_from : "", - (long long) vclock_sum(to), s_to ? s_to : ""); - free(s_from); - free(s_to); - } - virtual void raise() { throw this; } -}; - /* {{{ Initial recovery */ /** diff --git a/src/diag.h b/src/diag.h index 0ccf86d0..a0b71f04 100644 --- a/src/diag.h +++ b/src/diag.h @@ -248,8 +248,6 @@ BuildIllegalParams(const char *file, unsigned line, const char *format, ...); struct error * BuildSystemError(const char *file, unsigned line, const char *format, ...); struct error * -BuildXlogError(const char *file, unsigned line, const char *format, ...); -struct error * BuildCollationError(const char *file, unsigned line, const char *format, ...); struct index_def; -- 2.11.0
prev parent reply other threads:[~2018-06-29 16:48 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-06-29 16:48 [PATCH v2 0/6] Create empty xlog on shutdown Vladimir Davydov 2018-06-29 16:48 ` [PATCH v2 1/6] xlog: store prev vclock in xlog header Vladimir Davydov 2018-07-05 6:49 ` Konstantin Osipov 2018-07-05 6:52 ` Konstantin Osipov 2018-07-05 8:23 ` Vladimir Davydov 2018-07-05 11:22 ` Konstantin Osipov 2018-07-10 16:28 ` [PATCH] xlog: get rid of xlog_meta::has_prev_vclock Vladimir Davydov 2018-06-29 16:48 ` [PATCH v2 2/6] xlog: differentiate between closed and never opened cursor Vladimir Davydov 2018-06-29 16:48 ` [PATCH v2 3/6] recovery: make LSN gap check more thorough Vladimir Davydov 2018-06-29 16:48 ` [PATCH v2 4/6] recovery: promote recovery clock even if the WAL is empty Vladimir Davydov 2018-06-29 16:48 ` [PATCH v2 5/6] wal: create empty xlog on shutdown Vladimir Davydov 2018-06-29 16:48 ` Vladimir Davydov [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=c6932592681ff29d49880d026e82605a1bdf32da.1530287767.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v2 6/6] error: move XlogGapError to box/error.h' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox