From a6e066505b6982871bce1a3921ab471c925952ae Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Fri, 6 Mar 2009 17:56:05 +0000 Subject: [PATCH] Fixed CORE-2316: Throttling Nbackup on large databases --- configure.in | 3 ++- src/utilities/nbackup.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 02a9a255c8..639874ad86 100644 --- a/configure.in +++ b/configure.in @@ -661,7 +661,7 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" AC_CHECK_FUNCS(sem_timedwait) AC_CHECK_FUNCS(sem_init) if test "$ac_cv_func_sem_init" = "yes"; then -AC_MSG_CHECKING(for working sem_int()) +AC_MSG_CHECKING(for working sem_init()) AC_TRY_RUN([#include main () { sem_t s; @@ -675,6 +675,7 @@ fi CFLAGS="$savedFlags" fi AC_CHECK_FUNCS(semtimedop) +AC_CHECK_FUNCS(posix_fadvise) # Checks for typedefs, structures, and compiler characteristics. AC_C_BIGENDIAN diff --git a/src/utilities/nbackup.cpp b/src/utilities/nbackup.cpp index 436136ddac..5dc1cec7a8 100644 --- a/src/utilities/nbackup.cpp +++ b/src/utilities/nbackup.cpp @@ -366,10 +366,16 @@ void NBackup::open_database_scan() if (dbase == INVALID_HANDLE_VALUE) b_error::raise(uSvc, "Error (%d) opening database file: %s", GetLastError(), dbname.c_str()); #else - dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE); + dbase = open(dbname.c_str(), O_RDONLY | O_LARGEFILE | O_NOATIME | O_DIRECT); if (dbase < 0) b_error::raise(uSvc, "Error (%d) opening database file: %s", errno, dbname.c_str()); -#endif +#ifdef HAVE_POSIX_FADVISE + if (posix_fadvise(dbase, 0, 0, POSIX_FADV_SEQUENTIAL) < 0) + b_error::raise(uSvc, "Error (%d) in posix_fadvise(SEQUENTIAL) for %s", errno, dbname.c_str()); + if (posix_fadvise(dbase, 0, 0, POSIX_FADV_NOREUSE) < 0) + b_error::raise(uSvc, "Error (%d) in posix_fadvise(NOREUSE) for %s", errno, dbname.c_str()); +#endif //HAVE_POSIX_FADVISE +#endif //WIN_NT } void NBackup::create_database()