mirror of
https://github.com/XTXMarkets/ternfs.git
synced 2026-01-06 02:49:45 -06:00
Remove option to not write out atime which is too recent
This was pretty nasty to begin with, we now do it in the client.
This commit is contained in:
@@ -190,9 +190,6 @@ std::ostream& operator<<(std::ostream& out, EggsError err) {
|
||||
case EggsError::BLOCK_PARTIAL_IO_ERROR:
|
||||
out << "BLOCK_PARTIAL_IO_ERROR";
|
||||
break;
|
||||
case EggsError::TIME_TOO_RECENT:
|
||||
out << "TIME_TOO_RECENT";
|
||||
break;
|
||||
default:
|
||||
out << "EggsError(" << ((int)err) << ")";
|
||||
break;
|
||||
|
||||
@@ -66,7 +66,6 @@ enum class EggsError : uint16_t {
|
||||
BLOCK_TOO_OLD_FOR_WRITE = 69,
|
||||
BLOCK_IO_ERROR = 70,
|
||||
BLOCK_PARTIAL_IO_ERROR = 71,
|
||||
TIME_TOO_RECENT = 72,
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, EggsError err);
|
||||
@@ -134,10 +133,9 @@ const std::vector<EggsError> allEggsErrors {
|
||||
EggsError::BLOCK_TOO_OLD_FOR_WRITE,
|
||||
EggsError::BLOCK_IO_ERROR,
|
||||
EggsError::BLOCK_PARTIAL_IO_ERROR,
|
||||
EggsError::TIME_TOO_RECENT,
|
||||
};
|
||||
|
||||
constexpr int maxEggsError = 73;
|
||||
constexpr int maxEggsError = 72;
|
||||
|
||||
enum class ShardMessageKind : uint8_t {
|
||||
ERROR = 0,
|
||||
|
||||
@@ -77,11 +77,6 @@ public:
|
||||
EggsError err = db.prepareLogEntry(req, logEntry);
|
||||
if (err == NO_ERROR) {
|
||||
err = _applyLogEntryLocked(req.kind(), logEntry, resp);
|
||||
} else if (req.kind() == ShardMessageKind::SET_TIME && err == EggsError::TIME_TOO_RECENT) {
|
||||
// We don't want errors for this one to the client. We very
|
||||
// often send this request without waiting (to set atime) anyway.
|
||||
resp.setSetTime().clear();
|
||||
return NO_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@@ -590,7 +585,6 @@ void runShard(ShardId shid, const std::string& dbDir, const ShardOptions& option
|
||||
LOG_INFO(env, " simulateIncomingPacketDrop = %s", options.simulateIncomingPacketDrop);
|
||||
LOG_INFO(env, " simulateOutgoingPacketDrop = %s", options.simulateOutgoingPacketDrop);
|
||||
LOG_INFO(env, " syslog = %s", (int)options.syslog);
|
||||
LOG_INFO(env, " minAtimeInterval = %s", options.minAtimeInterval);
|
||||
}
|
||||
|
||||
// xmon first, so that by the time it shuts down it'll have all the leftover requests
|
||||
@@ -608,11 +602,7 @@ void runShard(ShardId shid, const std::string& dbDir, const ShardOptions& option
|
||||
|
||||
XmonNCAlert dbInitAlert;
|
||||
env.updateAlert(dbInitAlert, "initializing database");
|
||||
ShardDB db(logger, xmon, dbDir, ShardDBConfig{
|
||||
.shid = shid,
|
||||
.deadlineInterval = options.transientDeadlineInterval,
|
||||
.minAtimeInterval = options.minAtimeInterval,
|
||||
});
|
||||
ShardDB db(logger, xmon, shid, options.transientDeadlineInterval, dbDir);
|
||||
env.clearAlert(dbInitAlert);
|
||||
|
||||
ShardShared shared(db);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "Msgs.hpp"
|
||||
#include "Env.hpp"
|
||||
#include "ShardDB.hpp"
|
||||
@@ -30,7 +28,6 @@ struct ShardOptions {
|
||||
bool xmonProd = false;
|
||||
bool metrics = false;
|
||||
Duration transientDeadlineInterval = DEFAULT_DEADLINE_INTERVAL;
|
||||
Duration minAtimeInterval = std::numeric_limits<int64_t>::min();
|
||||
};
|
||||
|
||||
void runShard(ShardId shid, const std::string& dbDir, const ShardOptions& options);
|
||||
|
||||
@@ -158,7 +158,6 @@ struct ShardDBImpl {
|
||||
|
||||
ShardId _shid;
|
||||
Duration _transientDeadlineInterval;
|
||||
Duration _minAtimeInterval;
|
||||
std::array<uint8_t, 16> _secretKey;
|
||||
AES128Key _expandedSecretKey;
|
||||
|
||||
@@ -194,13 +193,12 @@ struct ShardDBImpl {
|
||||
|
||||
ShardDBImpl() = delete;
|
||||
|
||||
ShardDBImpl(Logger& logger, std::shared_ptr<XmonAgent>& xmon, const std::string& path, const ShardDBConfig& config) :
|
||||
ShardDBImpl(Logger& logger, std::shared_ptr<XmonAgent>& xmon, ShardId shid, Duration deadlineInterval, const std::string& path) :
|
||||
_env(logger, xmon, "shard_db"),
|
||||
_shid(config.shid),
|
||||
_transientDeadlineInterval(config.deadlineInterval),
|
||||
_minAtimeInterval(config.minAtimeInterval)
|
||||
_shid(shid),
|
||||
_transientDeadlineInterval(deadlineInterval)
|
||||
{
|
||||
LOG_INFO(_env, "will run shard %s in db dir %s", _shid, path);
|
||||
LOG_INFO(_env, "will run shard %s in db dir %s", shid, path);
|
||||
|
||||
// TODO actually figure out the best strategy for each family, including the default
|
||||
// one.
|
||||
@@ -1661,30 +1659,6 @@ struct ShardDBImpl {
|
||||
if (req.id.shard() != _shid) {
|
||||
return EggsError::BAD_SHARD;
|
||||
}
|
||||
|
||||
// check if we're within limits
|
||||
{
|
||||
std::string fileValue;
|
||||
ExternalValue<FileBody> file;
|
||||
EggsError err = _getFile({}, req.id, fileValue, file);
|
||||
if (err != NO_ERROR) {
|
||||
return err;
|
||||
}
|
||||
const auto check = [&file](uint64_t entryT, EggsTime (FileBody::*getTime)() const, Duration minInterval) {
|
||||
if (entryT & (1ull<<63)) {
|
||||
EggsTime t = entryT & ~(1ull<<63);
|
||||
if ((t - (file().*getTime)()) < minInterval) {
|
||||
return EggsError::TIME_TOO_RECENT;
|
||||
}
|
||||
}
|
||||
return NO_ERROR;
|
||||
};
|
||||
err = check(req.atime, &FileBody::atime, _minAtimeInterval);
|
||||
if (err != NO_ERROR) { return err; }
|
||||
err = check(req.mtime, &FileBody::mtime, std::numeric_limits<std::int64_t>::min());
|
||||
if (err != NO_ERROR) { return err; }
|
||||
}
|
||||
|
||||
entry.id = req.id;
|
||||
entry.atime = req.atime;
|
||||
entry.mtime = req.mtime;
|
||||
@@ -1794,9 +1768,6 @@ struct ShardDBImpl {
|
||||
if (err == NO_ERROR) {
|
||||
LOG_DEBUG(_env, "prepared log entry of kind %s, for request of kind %s", logEntryBody.kind(), req.kind());
|
||||
LOG_TRACE(_env, "log entry body: %s", logEntryBody);
|
||||
} else if (err == EggsError::TIME_TOO_RECENT) {
|
||||
// this is totally legitimate
|
||||
LOG_DEBUG(_env, "could not prepare log entry for request of kind %s: %s", req.kind(), err);
|
||||
} else {
|
||||
LOG_INFO(_env, "could not prepare log entry for request of kind %s: %s", req.kind(), err);
|
||||
}
|
||||
@@ -3841,8 +3812,8 @@ bool readOnlyShardReq(const ShardMessageKind kind) {
|
||||
throw EGGS_EXCEPTION("bad message kind %s", kind);
|
||||
}
|
||||
|
||||
ShardDB::ShardDB(Logger& logger, std::shared_ptr<XmonAgent>& agent, const std::string& path, const ShardDBConfig& config) {
|
||||
_impl = new ShardDBImpl(logger, agent, path, config);
|
||||
ShardDB::ShardDB(Logger& logger, std::shared_ptr<XmonAgent>& agent, ShardId shid, Duration deadlineInterval, const std::string& path) {
|
||||
_impl = new ShardDBImpl(logger, agent, shid, deadlineInterval, path);
|
||||
}
|
||||
|
||||
void ShardDB::close() {
|
||||
|
||||
@@ -28,12 +28,6 @@ constexpr uint32_t MAXIMUM_SPAN_SIZE = 100 << 20;
|
||||
|
||||
constexpr Duration DEFAULT_DEADLINE_INTERVAL = 2_hours;
|
||||
|
||||
struct ShardDBConfig {
|
||||
ShardId shid;
|
||||
Duration deadlineInterval = DEFAULT_DEADLINE_INTERVAL;
|
||||
Duration minAtimeInterval = std::numeric_limits<std::int64_t>::min();
|
||||
};
|
||||
|
||||
struct ShardDB {
|
||||
private:
|
||||
void* _impl;
|
||||
@@ -42,7 +36,7 @@ public:
|
||||
ShardDB() = delete;
|
||||
|
||||
// init/teardown
|
||||
ShardDB(Logger& logger, std::shared_ptr<XmonAgent>& xmon, const std::string& path, const ShardDBConfig& config);
|
||||
ShardDB(Logger& logger, std::shared_ptr<XmonAgent>& xmon, ShardId shid, Duration deadlineInterval, const std::string& path);
|
||||
~ShardDB();
|
||||
|
||||
// Stuff which might throw, and therefore not well suited to destructor.
|
||||
|
||||
@@ -37,8 +37,6 @@ static void usage(const char* binary) {
|
||||
fprintf(stderr, " Enable metrics.\n");
|
||||
fprintf(stderr, " -transient-deadline-interval\n");
|
||||
fprintf(stderr, " Tweaks the interval with wich the deadline for transient file gets bumped.\n");
|
||||
fprintf(stderr, " -min-atime-interval\n");
|
||||
fprintf(stderr, " If set, will only write atime if it's older than the given interval. Useful to remove writes due to atime.\n");
|
||||
}
|
||||
|
||||
static double parseDouble(const std::string& arg) {
|
||||
@@ -185,8 +183,6 @@ int main(int argc, char** argv) {
|
||||
options.metrics = true;
|
||||
} else if (arg == "-transient-deadline-interval") {
|
||||
options.transientDeadlineInterval = parseDuration(getNextArg());
|
||||
} else if (arg == "-min-atime-interval") {
|
||||
options.minAtimeInterval = parseDuration(getNextArg());
|
||||
} else {
|
||||
args.emplace_back(std::move(arg));
|
||||
}
|
||||
|
||||
@@ -395,14 +395,14 @@ struct TempShardDB {
|
||||
throw SYSCALL_EXCEPTION("mkdtemp");
|
||||
}
|
||||
std::shared_ptr<XmonAgent> xmon;
|
||||
db = std::make_unique<ShardDB>(logger, xmon, dbDir, ShardDBConfig{ .shid = shid });
|
||||
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, dbDir);
|
||||
}
|
||||
|
||||
// useful to test recovery
|
||||
void restart() {
|
||||
db->close();
|
||||
std::shared_ptr<XmonAgent> xmon;
|
||||
db = std::make_unique<ShardDB>(logger, xmon, dbDir, ShardDBConfig{ .shid = shid });
|
||||
db = std::make_unique<ShardDB>(logger, xmon, shid, DEFAULT_DEADLINE_INTERVAL, dbDir);
|
||||
}
|
||||
|
||||
~TempShardDB() {
|
||||
|
||||
@@ -1405,7 +1405,6 @@ func main() {
|
||||
"BLOCK_TOO_OLD_FOR_WRITE",
|
||||
"BLOCK_IO_ERROR",
|
||||
"BLOCK_PARTIAL_IO_ERROR",
|
||||
"TIME_TOO_RECENT",
|
||||
}
|
||||
|
||||
kernelShardReqResps := []reqRespType{
|
||||
|
||||
@@ -177,7 +177,6 @@ const (
|
||||
BLOCK_TOO_OLD_FOR_WRITE ErrCode = 69
|
||||
BLOCK_IO_ERROR ErrCode = 70
|
||||
BLOCK_PARTIAL_IO_ERROR ErrCode = 71
|
||||
TIME_TOO_RECENT ErrCode = 72
|
||||
)
|
||||
|
||||
func (err ErrCode) String() string {
|
||||
@@ -306,8 +305,6 @@ func (err ErrCode) String() string {
|
||||
return "BLOCK_IO_ERROR"
|
||||
case 71:
|
||||
return "BLOCK_PARTIAL_IO_ERROR"
|
||||
case 72:
|
||||
return "TIME_TOO_RECENT"
|
||||
default:
|
||||
return fmt.Sprintf("ErrCode(%d)", err)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ const char* eggsfs_err_str(int err) {
|
||||
case 69: return "BLOCK_TOO_OLD_FOR_WRITE";
|
||||
case 70: return "BLOCK_IO_ERROR";
|
||||
case 71: return "BLOCK_PARTIAL_IO_ERROR";
|
||||
case 72: return "TIME_TOO_RECENT";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,9 +63,8 @@
|
||||
#define EGGSFS_ERR_BLOCK_TOO_OLD_FOR_WRITE 69
|
||||
#define EGGSFS_ERR_BLOCK_IO_ERROR 70
|
||||
#define EGGSFS_ERR_BLOCK_PARTIAL_IO_ERROR 71
|
||||
#define EGGSFS_ERR_TIME_TOO_RECENT 72
|
||||
|
||||
#define __print_eggsfs_err(i) __print_symbolic(i, { 10, "INTERNAL_ERROR" }, { 11, "FATAL_ERROR" }, { 12, "TIMEOUT" }, { 13, "MALFORMED_REQUEST" }, { 14, "MALFORMED_RESPONSE" }, { 15, "NOT_AUTHORISED" }, { 16, "UNRECOGNIZED_REQUEST" }, { 17, "FILE_NOT_FOUND" }, { 18, "DIRECTORY_NOT_FOUND" }, { 19, "NAME_NOT_FOUND" }, { 20, "EDGE_NOT_FOUND" }, { 21, "EDGE_IS_LOCKED" }, { 22, "TYPE_IS_DIRECTORY" }, { 23, "TYPE_IS_NOT_DIRECTORY" }, { 24, "BAD_COOKIE" }, { 25, "INCONSISTENT_STORAGE_CLASS_PARITY" }, { 26, "LAST_SPAN_STATE_NOT_CLEAN" }, { 27, "COULD_NOT_PICK_BLOCK_SERVICES" }, { 28, "BAD_SPAN_BODY" }, { 29, "SPAN_NOT_FOUND" }, { 30, "BLOCK_SERVICE_NOT_FOUND" }, { 31, "CANNOT_CERTIFY_BLOCKLESS_SPAN" }, { 32, "BAD_NUMBER_OF_BLOCKS_PROOFS" }, { 33, "BAD_BLOCK_PROOF" }, { 34, "CANNOT_OVERRIDE_NAME" }, { 35, "NAME_IS_LOCKED" }, { 36, "MTIME_IS_TOO_RECENT" }, { 37, "MISMATCHING_TARGET" }, { 38, "MISMATCHING_OWNER" }, { 39, "MISMATCHING_CREATION_TIME" }, { 40, "DIRECTORY_NOT_EMPTY" }, { 41, "FILE_IS_TRANSIENT" }, { 42, "OLD_DIRECTORY_NOT_FOUND" }, { 43, "NEW_DIRECTORY_NOT_FOUND" }, { 44, "LOOP_IN_DIRECTORY_RENAME" }, { 45, "DIRECTORY_HAS_OWNER" }, { 46, "FILE_IS_NOT_TRANSIENT" }, { 47, "FILE_NOT_EMPTY" }, { 48, "CANNOT_REMOVE_ROOT_DIRECTORY" }, { 49, "FILE_EMPTY" }, { 50, "CANNOT_REMOVE_DIRTY_SPAN" }, { 51, "BAD_SHARD" }, { 52, "BAD_NAME" }, { 53, "MORE_RECENT_SNAPSHOT_EDGE" }, { 54, "MORE_RECENT_CURRENT_EDGE" }, { 55, "BAD_DIRECTORY_INFO" }, { 56, "DEADLINE_NOT_PASSED" }, { 57, "SAME_SOURCE_AND_DESTINATION" }, { 58, "SAME_DIRECTORIES" }, { 59, "SAME_SHARD" }, { 60, "BAD_PROTOCOL_VERSION" }, { 61, "BAD_CERTIFICATE" }, { 62, "BLOCK_TOO_RECENT_FOR_DELETION" }, { 63, "BLOCK_FETCH_OUT_OF_BOUNDS" }, { 64, "BAD_BLOCK_CRC" }, { 65, "BLOCK_TOO_BIG" }, { 66, "BLOCK_NOT_FOUND" }, { 67, "CANNOT_UNSET_DECOMMISSIONED" }, { 68, "CANNOT_REGISTER_DECOMMISSIONED" }, { 69, "BLOCK_TOO_OLD_FOR_WRITE" }, { 70, "BLOCK_IO_ERROR" }, { 71, "BLOCK_PARTIAL_IO_ERROR" }, { 72, "TIME_TOO_RECENT" })
|
||||
#define __print_eggsfs_err(i) __print_symbolic(i, { 10, "INTERNAL_ERROR" }, { 11, "FATAL_ERROR" }, { 12, "TIMEOUT" }, { 13, "MALFORMED_REQUEST" }, { 14, "MALFORMED_RESPONSE" }, { 15, "NOT_AUTHORISED" }, { 16, "UNRECOGNIZED_REQUEST" }, { 17, "FILE_NOT_FOUND" }, { 18, "DIRECTORY_NOT_FOUND" }, { 19, "NAME_NOT_FOUND" }, { 20, "EDGE_NOT_FOUND" }, { 21, "EDGE_IS_LOCKED" }, { 22, "TYPE_IS_DIRECTORY" }, { 23, "TYPE_IS_NOT_DIRECTORY" }, { 24, "BAD_COOKIE" }, { 25, "INCONSISTENT_STORAGE_CLASS_PARITY" }, { 26, "LAST_SPAN_STATE_NOT_CLEAN" }, { 27, "COULD_NOT_PICK_BLOCK_SERVICES" }, { 28, "BAD_SPAN_BODY" }, { 29, "SPAN_NOT_FOUND" }, { 30, "BLOCK_SERVICE_NOT_FOUND" }, { 31, "CANNOT_CERTIFY_BLOCKLESS_SPAN" }, { 32, "BAD_NUMBER_OF_BLOCKS_PROOFS" }, { 33, "BAD_BLOCK_PROOF" }, { 34, "CANNOT_OVERRIDE_NAME" }, { 35, "NAME_IS_LOCKED" }, { 36, "MTIME_IS_TOO_RECENT" }, { 37, "MISMATCHING_TARGET" }, { 38, "MISMATCHING_OWNER" }, { 39, "MISMATCHING_CREATION_TIME" }, { 40, "DIRECTORY_NOT_EMPTY" }, { 41, "FILE_IS_TRANSIENT" }, { 42, "OLD_DIRECTORY_NOT_FOUND" }, { 43, "NEW_DIRECTORY_NOT_FOUND" }, { 44, "LOOP_IN_DIRECTORY_RENAME" }, { 45, "DIRECTORY_HAS_OWNER" }, { 46, "FILE_IS_NOT_TRANSIENT" }, { 47, "FILE_NOT_EMPTY" }, { 48, "CANNOT_REMOVE_ROOT_DIRECTORY" }, { 49, "FILE_EMPTY" }, { 50, "CANNOT_REMOVE_DIRTY_SPAN" }, { 51, "BAD_SHARD" }, { 52, "BAD_NAME" }, { 53, "MORE_RECENT_SNAPSHOT_EDGE" }, { 54, "MORE_RECENT_CURRENT_EDGE" }, { 55, "BAD_DIRECTORY_INFO" }, { 56, "DEADLINE_NOT_PASSED" }, { 57, "SAME_SOURCE_AND_DESTINATION" }, { 58, "SAME_DIRECTORIES" }, { 59, "SAME_SHARD" }, { 60, "BAD_PROTOCOL_VERSION" }, { 61, "BAD_CERTIFICATE" }, { 62, "BLOCK_TOO_RECENT_FOR_DELETION" }, { 63, "BLOCK_FETCH_OUT_OF_BOUNDS" }, { 64, "BAD_BLOCK_CRC" }, { 65, "BLOCK_TOO_BIG" }, { 66, "BLOCK_NOT_FOUND" }, { 67, "CANNOT_UNSET_DECOMMISSIONED" }, { 68, "CANNOT_REGISTER_DECOMMISSIONED" }, { 69, "BLOCK_TOO_OLD_FOR_WRITE" }, { 70, "BLOCK_IO_ERROR" }, { 71, "BLOCK_PARTIAL_IO_ERROR" })
|
||||
const char* eggsfs_err_str(int err);
|
||||
|
||||
#define EGGSFS_SHARD_LOOKUP 0x1
|
||||
|
||||
@@ -62,7 +62,7 @@ bool eggsfs_unexpected_error(int err) {
|
||||
case EGGSFS_ERR_BAD_BLOCK_CRC: return true;
|
||||
case EGGSFS_ERR_BLOCK_TOO_BIG: return true;
|
||||
case EGGSFS_ERR_BLOCK_NOT_FOUND: return true;
|
||||
case EGGSFS_ERR_TIME_TOO_RECENT: return true;
|
||||
case EGGSFS_ERR_TIME_TOO_RECENT: return false;
|
||||
case -ERESTARTSYS: return false;
|
||||
case -ETIMEDOUT: return false;
|
||||
case -ECONNREFUSED: return false;
|
||||
|
||||
Reference in New Issue
Block a user