Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix db_stress for custom env #5122

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unnecessary close in HdfsLogger
Summary: unnecessary because HdfsLogger is not the owner of writable file. The
owner will close it on close or destruction.
  • Loading branch information
riversand963 committed Mar 28, 2019
commit e490f2a4b3ece8219cb1cc20aa2a8bbd760c6c88
13 changes: 6 additions & 7 deletions env/env_hdfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#ifndef ROCKSDB_HDFS_FILE_C
#define ROCKSDB_HDFS_FILE_C

#include <algorithm>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <algorithm>
#include <iostream>
#include <sstream>
#include "rocksdb/status.h"
Expand Down Expand Up @@ -253,7 +253,8 @@ class HdfsWritableFile: public WritableFile {

// This is used by HdfsLogger to write data to the debug log file
virtual Status Append(const char* src, size_t size) {
if (hdfsWrite(fileSys_, hfile_, src, static_cast<tSize>(size)) != static_cast<tSize>(size)) {
if (hdfsWrite(fileSys_, hfile_, src, static_cast<tSize>(size)) !=
static_cast<tSize>(size)) {
return IOError(filename_, errno);
}
return Status::OK();
Expand Down Expand Up @@ -281,11 +282,11 @@ class HdfsLogger : public Logger {
Status HdfsCloseHelper() {
ROCKS_LOG_DEBUG(mylog, "[hdfs] HdfsLogger closed %s\n",
file_->getName().c_str());
Status s = file_->Close();
// Status s = file_->Close();
if (mylog != nullptr && mylog == this) {
mylog = nullptr;
}
return s;
return Status::OK();
}

protected:
Expand Down Expand Up @@ -580,9 +581,7 @@ Status HdfsEnv::LockFile(const std::string& /*fname*/, FileLock** lock) {
return Status::OK();
}

Status HdfsEnv::UnlockFile(FileLock* /*lock*/) {
return Status::OK();
}
Status HdfsEnv::UnlockFile(FileLock* /*lock*/) { return Status::OK(); }

Status HdfsEnv::NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result) {
Expand Down
25 changes: 11 additions & 14 deletions hdfs/env_hdfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class HdfsEnv : public Env {
const EnvOptions& options) override;

Status NewDirectory(const std::string& name,
std::unique_ptr<Directory>* result) override;
std::unique_ptr<Directory>* result) override;

Status FileExists(const std::string& fname) override;

Expand All @@ -85,11 +85,12 @@ class HdfsEnv : public Env {
Status GetFileSize(const std::string& fname, uint64_t* size) override;

Status GetFileModificationTime(const std::string& fname,
uint64_t* file_mtime) override;
uint64_t* file_mtime) override;

Status RenameFile(const std::string& src, const std::string& target) override;

Status LinkFile(const std::string& /*src*/, const std::string& /*target*/) override {
Status LinkFile(const std::string& /*src*/,
const std::string& /*target*/) override {
return Status::NotSupported(); // not supported
}

Expand All @@ -100,8 +101,9 @@ class HdfsEnv : public Env {
Status NewLogger(const std::string& fname,
std::shared_ptr<Logger>* result) override;

void Schedule(void (*function)(void* arg), void* arg,
Priority pri = LOW, void* tag = nullptr, void (*unschedFunction)(void* arg) = 0) override {
void Schedule(void (*function)(void* arg), void* arg, Priority pri = LOW,
void* tag = nullptr,
void (*unschedFunction)(void* arg) = 0) override {
posixEnv->Schedule(function, arg, pri, tag, unschedFunction);
}

Expand All @@ -115,18 +117,15 @@ class HdfsEnv : public Env {

void WaitForJoin() override { posixEnv->WaitForJoin(); }

unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const
override {
unsigned int GetThreadPoolQueueLen(Priority pri = LOW) const override {
return posixEnv->GetThreadPoolQueueLen(pri);
}

Status GetTestDirectory(std::string* path) override {
return posixEnv->GetTestDirectory(path);
}

uint64_t NowMicros() override {
return posixEnv->NowMicros();
}
uint64_t NowMicros() override { return posixEnv->NowMicros(); }

void SleepForMicroseconds(int micros) override {
posixEnv->SleepForMicroseconds(micros);
Expand All @@ -141,7 +140,7 @@ class HdfsEnv : public Env {
}

Status GetAbsolutePath(const std::string& db_path,
std::string* output_path) override {
std::string* output_path) override {
return posixEnv->GetAbsolutePath(db_path, output_path);
}

Expand All @@ -166,9 +165,7 @@ class HdfsEnv : public Env {
return (uint64_t)pthread_self();
}

uint64_t GetThreadID() const override {
return HdfsEnv::gettid();
}
uint64_t GetThreadID() const override { return HdfsEnv::gettid(); }

private:
std::string fsname_; // string of the form "hdfs://hostname:port/"
Expand Down
3 changes: 2 additions & 1 deletion tools/db_stress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,8 @@ class StressTest {
options.env = FLAGS_env;
Status s = DestroyDB(FLAGS_db, options);
if (!s.ok()) {
fprintf(stderr, "Cannot destroy original db: %s\n", s.ToString().c_str());
fprintf(stderr, "Cannot destroy original db: %s\n",
s.ToString().c_str());
exit(1);
}
}
Expand Down