-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detecting if the data/log/wals allow file creation with O_DIRECT.
Summary: This code tests that data/logs/wals allow file creation with O_DIRECT flag and gives out an appropiate message if it cannot. If it does not and durable_wal_write flag is set, we check if the prefer_durable_write flag is set of not. If it is set, we crash with the appropiate error otherwise we soft downgrade durable_wal_write flag to false. Test Plan: 1) Unit test in path_util-test.cc 2) Simulate this by trying to create a cluster with WAL/Data dirs pointing to a file system that does not allow O_DIRECT writes. Reviewers: bogdan, mikhail Reviewed By: mikhail Subscribers: ybase, bharat Differential Revision: https://phabricator.dev.yugabyte.com/D4123
- Loading branch information
1 parent
d79f33a
commit 4c5813a
Showing
11 changed files
with
183 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) YugaByte, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed under the License | ||
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
// or implied. See the License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "yb/consensus/log_util.h" | ||
#include "yb/util/test_macros.h" | ||
|
||
namespace yb { | ||
|
||
#if defined(__linux__) | ||
TEST(TestLogUtil, TestModifyDurableWriteFlagIfNotDirectNegative) { | ||
gflags::FlagSaver flag_saver; | ||
FLAGS_fs_data_dirs = "/var/run"; | ||
|
||
// Test that the method does not crash and durable_wal_write is flipped | ||
// when directory is not O_DIRECT writable. | ||
FLAGS_durable_wal_write = true; | ||
FLAGS_require_durable_wal_write = false; | ||
ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect()); | ||
ASSERT_EQ(FLAGS_durable_wal_write, false); | ||
|
||
// Test that the method crashes when durable_wal_write is set to true. | ||
FLAGS_durable_wal_write = true; | ||
FLAGS_require_durable_wal_write = true; | ||
ASSERT_NOK(log::ModifyDurableWriteFlagIfNotODirect()); | ||
} | ||
#endif | ||
|
||
TEST(TestLogUtil, TestModifyDurableWriteFlagIfNotODirectPositive) { | ||
gflags::FlagSaver flag_saver; | ||
// Test that the method does not crash when durable_wal_write is set true and paths are O_DIRECT | ||
// Writable. | ||
FLAGS_durable_wal_write = true; | ||
ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect()); | ||
// Test that the method does not crash when durable_wal_write is set to false. | ||
FLAGS_durable_wal_write = false; | ||
ASSERT_OK(log::ModifyDurableWriteFlagIfNotODirect()); | ||
} | ||
} // namespace yb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters