Client: Retry a SYNC failed by a dropped connection by timer #182
@@ -1647,12 +1647,14 @@ resume_1:
|
||||
wb->fsync_error();
|
||||
if (op->retval == -EPIPE || op->retval == -EAGAIN || op->retval == -EIO || op->retval == -ENOSPC)
|
||||
{
|
||||
// Retry later
|
||||
// Retry later, by timer: no other event may be left to continue this SYNC
|
||||
op->retry_after = op->retval != -EPIPE && op->retval != -EAGAIN ? client_eio_retry_interval : client_retry_interval;
|
||||
op->parts.clear();
|
||||
op->retval = 0;
|
||||
op->inflight_count = 0;
|
||||
op->done_count = 0;
|
||||
op->state = 0;
|
||||
reset_retry_timer(op->retry_after);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ public:
|
||||
cli->continue_ops(cli->client_retry_interval);
|
||||
}
|
||||
|
||||
static int retry_interval(cluster_client_t *cli)
|
||||
{
|
||||
return cli->client_retry_interval;
|
||||
}
|
||||
|
||||
static void test_vault();
|
||||
};
|
||||
|
||||
@@ -1342,6 +1347,70 @@ void test_sync_fail_dirty_state_loss()
|
||||
printf("[ok] sync fail dirty state loss test\n");
|
||||
}
|
||||
|
||||
// A SYNC failed by a dropped connection must be retried by the client itself.
|
||||
//
|
||||
// The writes repeated for the dropped OSD go ahead of the SYNC, so the SYNC
|
||||
// resumes only after they complete. If that happens after the PG and peer
|
||||
// events, the retry timer is the only thing left to continue it. Without a
|
||||
// timer the SYNC stayed parked, and it and every write after it hung.
|
||||
void test_sync_retry_after_drop()
|
||||
{
|
||||
json11::Json config;
|
||||
// No fd handler: a mock clock advanced by tick()
|
||||
timerfd_manager_t *tfd = new timerfd_manager_t(NULL);
|
||||
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<etcd_state_client_t>(mock));
|
||||
timespec retry_tick = { .tv_sec = 0, .tv_nsec = (long)(cluster_client_test_t::retry_interval(cli)+10)*1000000 };
|
||||
|
||||
configure_single_pg_pool(mock);
|
||||
mock->resume();
|
||||
pretend_connected(cli, 1);
|
||||
pretend_connected(cli, 2);
|
||||
cluster_client_test_t::continue_ops(cli);
|
||||
|
||||
// A write completes on the primary OSD 1, then a SYNC goes to OSD 1
|
||||
int *r1 = test_write(cli, 0x1000, 0x1000, 0x55);
|
||||
can_complete(r1);
|
||||
cluster_client_test_t::continue_ops(cli);
|
||||
pretend_op_completed(cli, find_op(cli, 1, OSD_OP_WRITE, 0x1000, 0x1000), 0);
|
||||
check_completed(r1);
|
||||
int *r2 = test_sync(cli);
|
||||
cluster_client_test_t::continue_ops(cli);
|
||||
assert(find_op(cli, 1, OSD_OP_SYNC, 0, 0) != NULL);
|
||||
|
||||
// OSD 2 becomes the primary, and OSD 1 drops with the SYNC in flight
|
||||
mock->set("/vitastor/pg/state/1/1", json11::Json::object {
|
||||
{ "peers", json11::Json::array { 2 } },
|
||||
{ "primary", 2 },
|
||||
{ "state", json11::Json::array { "active" } },
|
||||
});
|
||||
pretend_disconnected(cli, 1);
|
||||
tfd->tick(retry_tick);
|
||||
|
||||
// The write repeated for OSD 1 goes to OSD 2, and the SYNC waits for it
|
||||
osd_op_t *rewrite = find_op(cli, 2, OSD_OP_WRITE, 0x1000, 0x1000);
|
||||
assert(rewrite != NULL);
|
||||
can_complete(r2);
|
||||
pretend_op_completed(cli, rewrite, 0);
|
||||
|
||||
// No event is left now, only the retry timer may resend the SYNC
|
||||
tfd->tick(retry_tick);
|
||||
osd_op_t *sync_op = find_op(cli, 2, OSD_OP_SYNC, 0, 0);
|
||||
if (sync_op == NULL)
|
||||
{
|
||||
printf("error: the SYNC failed by the dropped connection was never retried\n");
|
||||
}
|
||||
assert(sync_op != NULL);
|
||||
pretend_op_completed(cli, sync_op, 0);
|
||||
check_completed(r2);
|
||||
|
||||
delete cli;
|
||||
delete tfd;
|
||||
printf("[ok] sync retry after drop test\n");
|
||||
}
|
||||
|
||||
|
||||
int main(int narg, char *args[])
|
||||
{
|
||||
@@ -1355,6 +1424,7 @@ int main(int narg, char *args[])
|
||||
test_msgr_decrypt_chain();
|
||||
test_primary_change_flush_loss();
|
||||
test_sync_fail_dirty_state_loss();
|
||||
test_sync_retry_after_drop();
|
||||
cluster_client_test_t::test_vault();
|
||||
test_pg_config_disappears();
|
||||
test_sync_released_during_continue_ops();
|
||||
|
||||
Reference in New Issue
Block a user