Commit 63bc7424 authored by Rich Prohaska's avatar Rich Prohaska

#17 gracefull db open

parent a881aeae
...@@ -3534,10 +3534,13 @@ static int ft_create_file(FT_HANDLE UU(brt), const char *fname, int *fdp) { ...@@ -3534,10 +3534,13 @@ static int ft_create_file(FT_HANDLE UU(brt), const char *fname, int *fdp) {
} }
r = toku_fsync_directory(fname); r = toku_fsync_directory(fname);
resource_assert_zero(r); if (r == 0) {
*fdp = fd;
*fdp = fd; } else {
return 0; int rr = close(fd);
assert_zero(rr);
}
return r;
} }
// open a file for use by the brt. if the file does not exist, error // open a file for use by the brt. if the file does not exist, error
...@@ -3687,7 +3690,7 @@ ft_handle_open(FT_HANDLE ft_h, const char *fname_in_env, int is_create, int only ...@@ -3687,7 +3690,7 @@ ft_handle_open(FT_HANDLE ft_h, const char *fname_in_env, int is_create, int only
txn_created = (bool)(txn!=NULL); txn_created = (bool)(txn!=NULL);
toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, ft_h->options.flags, ft_h->options.nodesize, ft_h->options.basementnodesize, ft_h->options.compression_method); toku_logger_log_fcreate(txn, fname_in_env, reserved_filenum, mode, ft_h->options.flags, ft_h->options.nodesize, ft_h->options.basementnodesize, ft_h->options.compression_method);
r = ft_create_file(ft_h, fname_in_cwd, &fd); r = ft_create_file(ft_h, fname_in_cwd, &fd);
assert_zero(r); if (r) { goto exit; }
} }
if (r) { goto exit; } if (r) { goto exit; }
r=toku_cachetable_openfd_with_filenum(&cf, cachetable, fd, fname_in_env, reserved_filenum); r=toku_cachetable_openfd_with_filenum(&cf, cachetable, fd, fname_in_env, reserved_filenum);
......
...@@ -194,7 +194,6 @@ toku_rollback_fcreate (FILENUM filenum, ...@@ -194,7 +194,6 @@ toku_rollback_fcreate (FILENUM filenum,
// is not an error, but a missing file outside of recovery is. // is not an error, but a missing file outside of recovery is.
r = toku_cachefile_of_filenum(ct, filenum, &cf); r = toku_cachefile_of_filenum(ct, filenum, &cf);
if (r == ENOENT) { if (r == ENOENT) {
assert(txn->for_recovery);
r = 0; r = 0;
goto done; goto done;
} }
......
...@@ -133,6 +133,10 @@ PATENT RIGHTS GRANT: ...@@ -133,6 +133,10 @@ PATENT RIGHTS GRANT:
int int
toku_portability_init(void) { toku_portability_init(void) {
int r = toku_memory_startup(); int r = toku_memory_startup();
if (r == 0) {
uint64_t hz;
r = toku_os_get_processor_frequency(&hz);
}
return r; return r;
} }
...@@ -368,30 +372,37 @@ toku_get_processor_frequency_sysctl(const char * const cmd, uint64_t *hzret) { ...@@ -368,30 +372,37 @@ toku_get_processor_frequency_sysctl(const char * const cmd, uint64_t *hzret) {
if (!fp) { if (!fp) {
r = EINVAL; // popen doesn't return anything useful in errno, r = EINVAL; // popen doesn't return anything useful in errno,
// gotta pick something // gotta pick something
goto exit;
}
r = fscanf(fp, "%" SCNu64, hzret);
if (r != 1) {
r = get_maybe_error_errno();
} else { } else {
r = 0; r = fscanf(fp, "%" SCNu64, hzret);
if (r != 1) {
r = get_maybe_error_errno();
} else {
r = 0;
}
pclose(fp);
} }
pclose(fp);
exit:
return r; return r;
} }
int static uint64_t toku_cached_hz; // cache the value of hz so that we avoid opening files to compute it later
int
toku_os_get_processor_frequency(uint64_t *hzret) { toku_os_get_processor_frequency(uint64_t *hzret) {
int r; int r;
r = toku_get_processor_frequency_sys(hzret); if (toku_cached_hz) {
if (r != 0) *hzret = toku_cached_hz;
r = toku_get_processor_frequency_cpuinfo(hzret); r = 0;
if (r != 0) } else {
r = toku_get_processor_frequency_sysctl("sysctl -n hw.cpufrequency", hzret); r = toku_get_processor_frequency_sys(hzret);
if (r != 0) if (r != 0)
r = toku_get_processor_frequency_sysctl("sysctl -n machdep.tsc_freq", hzret); r = toku_get_processor_frequency_cpuinfo(hzret);
if (r != 0)
r = toku_get_processor_frequency_sysctl("sysctl -n hw.cpufrequency", hzret);
if (r != 0)
r = toku_get_processor_frequency_sysctl("sysctl -n machdep.tsc_freq", hzret);
if (r == 0)
toku_cached_hz = *hzret;
}
return r; return r;
} }
...@@ -439,3 +450,10 @@ double tokutime_to_seconds(tokutime_t t) { ...@@ -439,3 +450,10 @@ double tokutime_to_seconds(tokutime_t t) {
} }
return t*seconds_per_clock; return t*seconds_per_clock;
} }
#include <toku_race_tools.h>
void __attribute__((constructor)) toku_portability_helgrind_ignore(void);
void
toku_portability_helgrind_ignore(void) {
TOKU_VALGRIND_HG_DISABLE_CHECKING(&toku_cached_hz, sizeof toku_cached_hz);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment