From e1f101dfff3270906be63d85621c64039e5b88a8 Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Sun, 29 Nov 2026 11:29:10 +0300 Subject: [PATCH 1/2] Fail the fio job instead of exiting the process on a client error The fio engine left client_exit_on_error at its default, so a fatal client error at start (for example an invalid osd_network mask in etcd) called exit() inside the fio job, and fio then crashed. Disable the exit like the QEMU driver does and fail the job's setup with the client's error. An aborted client still accepted new ops and never completed them: continue_rw() returns at once when the client is aborted, so a job without -image hung on its first I/O. Fail ops on an aborted client with ECANCELED, including the ones still waiting for PGs when the error comes, because an error that stops the PG load would leave them waiting forever. --- src/client/cluster_client.cpp | 15 +++++++++++++++ src/client/fio_cluster.cpp | 9 +++++++++ src/test/test_cluster_client.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/client/cluster_client.cpp b/src/client/cluster_client.cpp index 38e4e7ba..b1fa68af 100644 --- a/src/client/cluster_client.cpp +++ b/src/client/cluster_client.cpp @@ -148,6 +148,14 @@ void cluster_client_t::fatal_error(int errcode, const std::string & error) } aborted = true; abort_error = error; + if (!pgs_loaded) + { + // PGs may never load now, so fail the queued ops instead of leaving them hanging + auto ops = std::move(offline_ops); + offline_ops.clear(); + for (auto op: ops) + execute(op); + } } cluster_op_t::~cluster_op_t() @@ -803,6 +811,13 @@ void cluster_client_t::execute(cluster_op_t *op) cb(op); return; } + if (aborted) + { + op->retval = -ECANCELED; + auto cb = std::move(op->callback); + cb(op); + return; + } if (!pgs_loaded) { offline_ops.push_back(op); diff --git a/src/client/fio_cluster.cpp b/src/client/fio_cluster.cpp index 3515d96a..0d1ab197 100644 --- a/src/client/fio_cluster.cpp +++ b/src/client/fio_cluster.cpp @@ -293,6 +293,8 @@ static int sec_setup(struct thread_data *td) opt_push(options, "log_level", std::to_string(o->cluster_log).c_str()); // allow writeback caching if -direct is not set opt_push(options, "client_writeback_allowed", td->o.odirect ? "0" : "1"); + // fio crashes if an engine calls exit(), so report client errors to fio instead + opt_push(options, "client_exit_on_error", "0"); bsd->cli = o->no_io_uring ? NULL : vitastor_c_create_uring_json((const char**)options.data(), options.size()); bsd->epoll_based = false; if (!bsd->cli) @@ -330,6 +332,13 @@ static int sec_setup(struct thread_data *td) vitastor_c_epoll_handle_events(bsd->cli, 1000); } } + char *err = NULL; + if (vitastor_c_is_failed(bsd->cli, &err)) + { + td_verror(td, EIO, err); + free(err); + return 1; + } td->files[0]->real_file_size = vitastor_c_inode_get_size(bsd->watch); if (!vitastor_c_inode_get_num(bsd->watch) || !td->files[0]->real_file_size) diff --git a/src/test/test_cluster_client.cpp b/src/test/test_cluster_client.cpp index 8b10f347..b2df7f54 100644 --- a/src/test/test_cluster_client.cpp +++ b/src/test/test_cluster_client.cpp @@ -21,6 +21,11 @@ public: } static void test_vault(); + + static void fatal_error(cluster_client_t *cli) + { + cli->fatal_error(EINVAL, "test error"); + } }; void configure_single_pg_pool(etcd_state_client_mock_t *mock, const char *immediate_commit = "none") @@ -1153,6 +1158,27 @@ void test_sync_released_during_continue_ops() printf("[ok] test_sync_released_during_continue_ops\n"); } +void test_abort_before_ready() +{ + json11::Json config = json11::Json::object { { "client_exit_on_error", false } }; + timerfd_manager_t *tfd = new timerfd_manager_t([](int fd, bool wr, std::function callback){}); + etcd_mock_t etcd_store; + etcd_state_client_mock_t *mock = new etcd_state_client_mock_t(etcd_store); + mock->pause(); + cluster_client_t *cli = new cluster_client_t(NULL, tfd, config, std::unique_ptr(mock)); + + // PGs are not loaded yet, so the write waits; a fatal error must fail it instead of leaving it hanging + int *r1 = test_write(cli, 0, 4096, 0x55); + can_complete(r1); + cluster_client_test_t::fatal_error(cli); + assert(*r1 == -ECANCELED); + delete r1; + + delete cli; + delete tfd; + printf("[ok] test_abort_before_ready\n"); +} + void test_snapshot_over_nonexistent_pool() { json11::Json config; @@ -1421,5 +1447,6 @@ int main(int narg, char *args[]) test_pg_config_disappears(); test_sync_released_during_continue_ops(); test_snapshot_over_nonexistent_pool(); + test_abort_before_ready(); return 0; } -- 2.47.3 From 303f7e662310a3c91be91877a02971a1abe20c6e Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Sun, 29 Nov 2026 14:54:59 +0300 Subject: [PATCH 2/2] Fail fio's getevents when the client has failed Operations already sent to OSDs never complete on a failed client, so a fatal error during the job (for example etcd cancelling the client's watch) left fio waiting in getevents forever now that the client no longer exits. Return EIO from getevents when the client has failed and nothing it waits for has completed. --- src/client/fio_cluster.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/client/fio_cluster.cpp b/src/client/fio_cluster.cpp index 0d1ab197..e0b3c111 100644 --- a/src/client/fio_cluster.cpp +++ b/src/client/fio_cluster.cpp @@ -478,6 +478,15 @@ static enum fio_q_status sec_queue(struct thread_data *td, struct io_u *io) return FIO_Q_QUEUED; } +// Operations in flight never complete on a failed client +static bool sec_client_failed(sec_data *bsd) +{ + char *err = NULL; + int failed = vitastor_c_is_failed(bsd->cli, &err); + free(err); + return failed; +} + static int sec_getevents(struct thread_data *td, unsigned int min, unsigned int max, const struct timespec *t) { sec_data *bsd = (sec_data*)td->io_ops_data; @@ -488,6 +497,8 @@ static int sec_getevents(struct thread_data *td, unsigned int min, unsigned int vitastor_c_uring_handle_events(bsd->cli); if (bsd->completed.size() >= min) break; + if (sec_client_failed(bsd)) + return -EIO; vitastor_c_uring_wait_events(bsd->cli); } } @@ -497,6 +508,8 @@ static int sec_getevents(struct thread_data *td, unsigned int min, unsigned int { if (bsd->completed.size() >= min) break; + if (sec_client_failed(bsd)) + return -EIO; vitastor_c_epoll_handle_events(bsd->cli, 1000); } } -- 2.47.3