Commit e9c99ea9 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

merge 1032 to 1032b. addresses #1231

git-svn-id: file:///svn/toku/tokudb.1032b@7814 c7de825b-a66e-492c-adef-691d508d4ae1
parent 93462fa4
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
The error handling routines for ydb The error handling routines for ydb
*/ */
#include "portability.h"
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -83,10 +84,6 @@ void toku_ydb_error_all_cases(const DB_ENV * env, ...@@ -83,10 +84,6 @@ void toku_ydb_error_all_cases(const DB_ENV * env,
toku__ydb_error_file(env, use_stderr_if_nothing_else, buf); toku__ydb_error_file(env, use_stderr_if_nothing_else, buf);
} }
int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *string, ...)
__attribute__((__format__(__printf__, 3, 4)));
/** Handle all the error cases (but don't do the default thing.) /** Handle all the error cases (but don't do the default thing.)
\param dbenv The environment that is subject to errors \param dbenv The environment that is subject to errors
\param error The error code \param error The error code
...@@ -101,10 +98,6 @@ int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *fmt, ...) { ...@@ -101,10 +98,6 @@ int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *fmt, ...) {
return error; return error;
} }
void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...)
__attribute__((__format__(__printf__, 3, 4)));
/** Handle errors on an environment, guarded by the ydb lock /** Handle errors on an environment, guarded by the ydb lock
\param dbenv The environment that is subject to errors \param dbenv The environment that is subject to errors
\param error The error code \param error The error code
......
...@@ -267,7 +267,7 @@ static int tokutrace_db_open(DB * db, DB_TXN * txn, const char *fname, const cha ...@@ -267,7 +267,7 @@ static int tokutrace_db_open(DB * db, DB_TXN * txn, const char *fname, const cha
if (tracefile) { if (tracefile) {
fprintf(tracefile, "db_open %d %d %d %s %s %d %u %d\n", fprintf(tracefile, "db_open %d %d %d %s %s %d %u %d\n",
r, r,
dbpairnum(db), txnpairnum(txn), fname, dbname, dbtype, flags, mode); dbpairnum(db), txnpairnum(txn), fname, dbname, (int)dbtype, flags, mode);
} }
tunlock(); tunlock();
return r; return r;
......
...@@ -88,6 +88,8 @@ struct __toku_dbc_internal { ...@@ -88,6 +88,8 @@ struct __toku_dbc_internal {
Ephemeral locking Ephemeral locking
********************************************************* */ ********************************************************* */
void toku_ydb_lock_init(void);
void toku_ydb_lock_destroy(void);
void toku_ydb_lock(void); void toku_ydb_lock(void);
void toku_ydb_unlock(void); void toku_ydb_unlock(void);
...@@ -121,7 +123,9 @@ void toku_ydb_error_all_cases(const DB_ENV * env, ...@@ -121,7 +123,9 @@ void toku_ydb_error_all_cases(const DB_ENV * env,
const char *fmt, va_list ap) const char *fmt, va_list ap)
__attribute__((format (printf, 5, 0))) __attribute__((format (printf, 5, 0)))
__attribute__((__visibility__("default"))); // this is needed by the C++ interface. __attribute__((__visibility__("default"))); // this is needed by the C++ interface.
int toku_ydb_do_error (const DB_ENV *, int, const char *, ...);
int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *string, ...)
__attribute__((__format__(__printf__, 3, 4)));
/* Location specific debug print-outs */ /* Location specific debug print-outs */
void toku_ydb_barf(void); void toku_ydb_barf(void);
...@@ -129,6 +133,7 @@ void toku_ydb_notef(const char *, ...); ...@@ -129,6 +133,7 @@ void toku_ydb_notef(const char *, ...);
/* Environment related errors */ /* Environment related errors */
int toku_env_is_panicked(DB_ENV *dbenv); int toku_env_is_panicked(DB_ENV *dbenv);
void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...); void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...)
__attribute__((__format__(__printf__, 3, 4)));
#endif #endif
...@@ -772,11 +772,11 @@ static int toku_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags ...@@ -772,11 +772,11 @@ static int toku_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags
} }
#if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1
void toku_default_errcall(const char *errpfx, char *msg) { static void toku_default_errcall(const char *errpfx, char *msg) {
fprintf(stderr, "YDB: %s: %s", errpfx, msg); fprintf(stderr, "YDB: %s: %s", errpfx, msg);
} }
#else #else
void toku_default_errcall(const DB_ENV *env, const char *errpfx, const char *msg) { static void toku_default_errcall(const DB_ENV *env, const char *errpfx, const char *msg) {
env = env; env = env;
fprintf(stderr, "YDB: %s: %s", errpfx, msg); fprintf(stderr, "YDB: %s: %s", errpfx, msg);
} }
...@@ -1135,7 +1135,6 @@ int txn_commit(DB_TXN * txn, u_int32_t flags) { ...@@ -1135,7 +1135,6 @@ int txn_commit(DB_TXN * txn, u_int32_t flags) {
} }
#endif #endif
int log_compare(const DB_LSN * a, const DB_LSN * b) __attribute__((__noreturn__));
int log_compare(const DB_LSN * a, const DB_LSN * b) { int log_compare(const DB_LSN * a, const DB_LSN * b) {
toku_ydb_lock(); toku_ydb_lock();
fprintf(stderr, "%s:%d log_compare(%p,%p)\n", __FILE__, __LINE__, a, b); fprintf(stderr, "%s:%d log_compare(%p,%p)\n", __FILE__, __LINE__, a, b);
...@@ -2970,7 +2969,7 @@ static int toku_db_put_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data, ...@@ -2970,7 +2969,7 @@ static int toku_db_put_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data,
} else { } else {
unsigned int limit = nodesize / (3*BRT_FANOUT-1); unsigned int limit = nodesize / (3*BRT_FANOUT-1);
if (key->size >= limit || data->size >= limit) if (key->size >= limit || data->size >= limit)
return toku_ydb_do_error(db->dbenv, EINVAL, "The largest key or data item allowed is %d bytes", limit); return toku_ydb_do_error(db->dbenv, EINVAL, "The largest key or data item allowed is %u bytes", limit);
} }
u_int32_t lock_flags = get_prelocked_flags(flags, txn); u_int32_t lock_flags = get_prelocked_flags(flags, txn);
flags &= ~lock_flags; flags &= ~lock_flags;
...@@ -3219,7 +3218,7 @@ static int toku_db_key_range64(DB* db, DB_TXN* txn __attribute__((__unused__)), ...@@ -3219,7 +3218,7 @@ static int toku_db_key_range64(DB* db, DB_TXN* txn __attribute__((__unused__)),
return r; return r;
} }
int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) { static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
HANDLE_PANICKED_DB(db); HANDLE_PANICKED_DB(db);
if (!db->i->lt || !txn) return EINVAL; if (!db->i->lt || !txn) return EINVAL;
//READ_UNCOMMITTED transactions do not need read locks. //READ_UNCOMMITTED transactions do not need read locks.
...@@ -3236,7 +3235,7 @@ int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, cons ...@@ -3236,7 +3235,7 @@ int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, cons
return r; return r;
} }
int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) { static int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
HANDLE_PANICKED_DB(db); HANDLE_PANICKED_DB(db);
if (!db->i->lt || !txn) return EINVAL; if (!db->i->lt || !txn) return EINVAL;
...@@ -3346,14 +3345,14 @@ static int locked_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_ ...@@ -3346,14 +3345,14 @@ static int locked_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_
toku_ydb_lock(); int r = autotxn_db_get(db, txn, key, data, flags); toku_ydb_unlock(); return r; toku_ydb_lock(); int r = autotxn_db_get(db, txn, key, data, flags); toku_ydb_unlock(); return r;
} }
int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) { static int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
toku_ydb_lock(); toku_ydb_lock();
int r = toku_db_pre_acquire_read_lock(db, txn, key_left, val_left, key_right, val_right); int r = toku_db_pre_acquire_read_lock(db, txn, key_left, val_left, key_right, val_right);
toku_ydb_unlock(); toku_ydb_unlock();
return r; return r;
} }
int locked_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) { static int locked_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
toku_ydb_lock(); toku_ydb_lock();
int r = toku_db_pre_acquire_table_lock(db, txn); int r = toku_db_pre_acquire_table_lock(db, txn);
toku_ydb_unlock(); toku_ydb_unlock();
......
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