@@ -623,56 +623,80 @@ ydb_recover_log_exists(DB_ENV *env) {
623623}
624624
625625// Validate that all required files are present, no side effects.
626- // Return 0 if all is well, ENOENT if some files are present but at least one is missing,
626+ // Return 0 if all is well, ENOENT if some files are present but at least one is
627+ // missing,
627628// other non-zero value if some other error occurs.
628629// Set *valid_newenv if creating a new environment (all files missing).
629- // (Note, if special dictionaries exist, then they were created transactionally and log should exist.)
630- static int
631- validate_env (DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) {
630+ // (Note, if special dictionaries exist, then they were created transactionally
631+ // and log should exist.)
632+ static int validate_env (DB_ENV *env,
633+ bool *valid_newenv,
634+ bool need_rollback_cachefile) {
632635 int r;
633- bool expect_newenv = false ; // set true if we expect to create a new env
636+ bool expect_newenv = false ; // set true if we expect to create a new env
634637 toku_struct_stat buf;
635- char * path = NULL ;
638+ char * path = NULL ;
636639
637640 // Test for persistent environment
638- path = toku_construct_full_name (2 , env->i ->dir , toku_product_name_strings.environmentdictionary );
641+ path = toku_construct_full_name (
642+ 2 , env->i ->dir , toku_product_name_strings.environmentdictionary );
639643 assert (path);
640644 r = toku_stat (path, &buf);
641645 if (r == 0 ) {
642646 expect_newenv = false ; // persistent info exists
643- }
644- else {
647+ } else {
645648 int stat_errno = get_error_errno ();
646649 if (stat_errno == ENOENT) {
647650 expect_newenv = true ;
648651 r = 0 ;
649- }
650- else {
651- r = toku_ydb_do_error (env, stat_errno, " Unable to access persistent environment\n " );
652+ } else {
653+ r = toku_ydb_do_error (
654+ env,
655+ stat_errno,
656+ " Unable to access persistent environment [%s] in [%s]\n " ,
657+ toku_product_name_strings.environmentdictionary ,
658+ env->i ->dir );
652659 assert (r);
653660 }
654661 }
655662 toku_free (path);
656663
657664 // Test for existence of rollback cachefile if it is expected to exist
658665 if (r == 0 && need_rollback_cachefile) {
659- path = toku_construct_full_name (2 , env->i ->dir , toku_product_name_strings.rollback_cachefile );
666+ path = toku_construct_full_name (
667+ 2 , env->i ->dir , toku_product_name_strings.rollback_cachefile );
660668 assert (path);
661669 r = toku_stat (path, &buf);
662- if (r == 0 ) {
663- if (expect_newenv) // rollback cachefile exists, but persistent env is missing
664- r = toku_ydb_do_error (env, ENOENT, " Persistent environment is missing\n " );
665- }
666- else {
670+ if (r == 0 ) {
671+ if (expect_newenv) // rollback cachefile exists, but persistent env
672+ // is missing
673+ r = toku_ydb_do_error (
674+ env,
675+ ENOENT,
676+ " Persistent environment is missing while looking for "
677+ " rollback cachefile [%s] in [%s]\n " ,
678+ toku_product_name_strings.rollback_cachefile , env->i ->dir );
679+ } else {
667680 int stat_errno = get_error_errno ();
668681 if (stat_errno == ENOENT) {
669- if (!expect_newenv) // rollback cachefile is missing but persistent env exists
670- r = toku_ydb_do_error (env, ENOENT, " rollback cachefile directory is missing\n " );
671- else
672- r = 0 ; // both rollback cachefile and persistent env are missing
673- }
674- else {
675- r = toku_ydb_do_error (env, stat_errno, " Unable to access rollback cachefile\n " );
682+ if (!expect_newenv) // rollback cachefile is missing but
683+ // persistent env exists
684+ r = toku_ydb_do_error (
685+ env,
686+ ENOENT,
687+ " rollback cachefile [%s] is missing from [%s]\n " ,
688+ toku_product_name_strings.rollback_cachefile ,
689+ env->i ->dir );
690+ else
691+ r = 0 ; // both rollback cachefile and persistent env are
692+ // missing
693+ } else {
694+ r = toku_ydb_do_error (
695+ env,
696+ stat_errno,
697+ " Unable to access rollback cachefile [%s] in [%s]\n " ,
698+ toku_product_name_strings.rollback_cachefile ,
699+ env->i ->dir );
676700 assert (r);
677701 }
678702 }
@@ -681,23 +705,41 @@ validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) {
681705
682706 // Test for fileops directory
683707 if (r == 0 ) {
684- path = toku_construct_full_name (2 , env->i ->dir , toku_product_name_strings.fileopsdirectory );
708+ path = toku_construct_full_name (
709+ 2 , env->i ->dir , toku_product_name_strings.fileopsdirectory );
685710 assert (path);
686711 r = toku_stat (path, &buf);
687- if (r == 0 ) {
688- if (expect_newenv) // fileops directory exists, but persistent env is missing
689- r = toku_ydb_do_error (env, ENOENT, " Persistent environment is missing\n " );
690- }
691- else {
712+ if (r == 0 ) {
713+ if (expect_newenv) // fileops directory exists, but persistent env
714+ // is missing
715+ r = toku_ydb_do_error (
716+ env,
717+ ENOENT,
718+ " Persistent environment is missing while looking for "
719+ " fileops directory [%s] in [%s]\n " ,
720+ toku_product_name_strings.fileopsdirectory ,
721+ env->i ->dir );
722+ } else {
692723 int stat_errno = get_error_errno ();
693724 if (stat_errno == ENOENT) {
694- if (!expect_newenv) // fileops directory is missing but persistent env exists
695- r = toku_ydb_do_error (env, ENOENT, " Fileops directory is missing\n " );
696- else
697- r = 0 ; // both fileops directory and persistent env are missing
698- }
699- else {
700- r = toku_ydb_do_error (env, stat_errno, " Unable to access fileops directory\n " );
725+ if (!expect_newenv) // fileops directory is missing but
726+ // persistent env exists
727+ r = toku_ydb_do_error (
728+ env,
729+ ENOENT,
730+ " Fileops directory [%s] is missing from [%s]\n " ,
731+ toku_product_name_strings.fileopsdirectory ,
732+ env->i ->dir );
733+ else
734+ r = 0 ; // both fileops directory and persistent env are
735+ // missing
736+ } else {
737+ r = toku_ydb_do_error (
738+ env,
739+ stat_errno,
740+ " Unable to access fileops directory [%s] in [%s]\n " ,
741+ toku_product_name_strings.fileopsdirectory ,
742+ env->i ->dir );
701743 assert (r);
702744 }
703745 }
@@ -709,16 +751,26 @@ validate_env(DB_ENV * env, bool * valid_newenv, bool need_rollback_cachefile) {
709751 // if using transactions, test for existence of log
710752 r = ydb_recover_log_exists (env); // return 0 or ENOENT
711753 if (expect_newenv && (r != ENOENT))
712- r = toku_ydb_do_error (env, ENOENT, " Persistent environment information is missing (but log exists)\n " );
754+ r = toku_ydb_do_error (env,
755+ ENOENT,
756+ " Persistent environment information is "
757+ " missing (but log exists) while looking for "
758+ " recovery log files in [%s]\n " ,
759+ env->i ->real_log_dir );
713760 else if (!expect_newenv && r == ENOENT)
714- r = toku_ydb_do_error (env, ENOENT, " Recovery log is missing (persistent environment information is present)\n " );
761+ r = toku_ydb_do_error (env,
762+ ENOENT,
763+ " Recovery log is missing (persistent "
764+ " environment information is present) while "
765+ " looking for recovery log files in [%s]\n " ,
766+ env->i ->real_log_dir );
715767 else
716768 r = 0 ;
717769 }
718770
719771 if (r == 0 )
720772 *valid_newenv = expect_newenv;
721- else
773+ else
722774 *valid_newenv = false ;
723775 return r;
724776}
@@ -768,7 +820,7 @@ env_open(DB_ENV * env, const char *home, uint32_t flags, int mode) {
768820 goto cleanup;
769821 }
770822
771- if (toku_os_huge_pages_enabled ()) {
823+ if (env-> get_check_thp (env) && toku_os_huge_pages_enabled ()) {
772824 r = toku_ydb_do_error (env, TOKUDB_HUGE_PAGES_ENABLED,
773825 " Huge pages are enabled, disable them before continuing\n " );
774826 goto cleanup;
@@ -1234,6 +1286,18 @@ env_set_checkpoint_pool_threads(DB_ENV * env, uint32_t threads) {
12341286 return 0 ;
12351287}
12361288
1289+ static void
1290+ env_set_check_thp (DB_ENV * env, bool new_val) {
1291+ assert (env);
1292+ env->i ->check_thp = new_val;
1293+ }
1294+
1295+ static bool
1296+ env_get_check_thp (DB_ENV * env) {
1297+ assert (env);
1298+ return env->i ->check_thp ;
1299+ }
1300+
12371301static int env_dbremove (DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbname, uint32_t flags);
12381302
12391303static int
@@ -2634,6 +2698,8 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) {
26342698 USENV (get_loader_memory_size);
26352699 USENV (set_killed_callback);
26362700 USENV (do_backtrace);
2701+ USENV (set_check_thp);
2702+ USENV (get_check_thp);
26372703#undef USENV
26382704
26392705 // unlocked methods
@@ -2659,6 +2725,8 @@ toku_env_create(DB_ENV ** envp, uint32_t flags) {
26592725 env_fs_init (result);
26602726 env_fsync_log_init (result);
26612727
2728+ result->i ->check_thp = true ;
2729+
26622730 result->i ->bt_compare = toku_builtin_compare_fun;
26632731
26642732 r = toku_logger_create (&result->i ->logger );
0 commit comments