~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/srv/srv0start.c

  • Committer: Barry.Leslie at PrimeBase
  • Date: 2010-10-20 20:41:00 UTC
  • mfrom: (1863 staging)
  • mto: This revision was merged to the branch mainline in revision 1871.
  • Revision ID: barry.leslie@primebase.com-20101020204100-oyj6p5cfssjw3p62
Merged with trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
# include "row0row.h"
104
104
# include "row0mysql.h"
105
105
# include "btr0pcur.h"
 
106
# include "thr0loc.h"
 
107
# include "os0sync.h" /* for INNODB_RW_LOCKS_USE_ATOMICS */
106
108
 
107
109
#include <errno.h>
108
110
#include <unistd.h>
496
498
                ios++;
497
499
                mutex_exit(&ios_mutex);
498
500
        }
499
 
 
500
501
        /* We count the number of threads in os_thread_exit(). A created
501
502
        thread should always use that to exit and not use return() to exit.
502
503
        The thread actually never comes here because it is exited in an
503
504
        os_event_wait(). */
504
505
#if (!defined(__SUNPRO_C) && !defined(__SUNPRO_CC))
 
506
        /* This is disabled on SunStudio as it (rightly) gives a warning
 
507
           about this code never being reached. See the loop above? No exit
 
508
           condition. */
 
509
        thr_local_free(os_thread_get_curr_id());
 
510
 
505
511
        return 0;
506
512
#endif
507
513
}
532
538
#endif
533
539
}
534
540
 
535
 
/*********************************************************************//**
536
 
Adds a slash or a backslash to the end of a string if it is missing
537
 
and the string is not empty.
538
 
@return string which has the separator if the string is not empty */
539
 
UNIV_INTERN
540
 
char*
541
 
srv_add_path_separator_if_needed(
542
 
/*=============================*/
543
 
        char*   str)    /*!< in: null-terminated character string */
544
 
{
545
 
        char*   out_str;
546
 
        ulint   len     = ut_strlen(str);
547
 
 
548
 
        if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
549
 
 
550
 
                return(str);
551
 
        }
552
 
 
553
 
        out_str = ut_malloc(len + 2);
554
 
        memcpy(out_str, str, len);
555
 
        out_str[len] = SRV_PATH_SEPARATOR;
556
 
        out_str[len + 1] = 0;
557
 
 
558
 
        return(out_str);
559
 
}
560
 
 
561
541
#ifndef UNIV_HOTBACKUP
562
542
/*********************************************************************//**
563
543
Calculates the low 32 bits when a file size which is given as a number
606
586
        ulint   size;
607
587
        ulint   size_high;
608
588
        char    name[10000];
 
589
        ulint   dirnamelen;
609
590
 
610
591
        UT_NOT_USED(create_new_db);
611
592
 
612
593
        *log_file_created = FALSE;
613
594
 
614
595
        srv_normalize_path_for_win(srv_log_group_home_dirs[k]);
615
 
        srv_log_group_home_dirs[k] = srv_add_path_separator_if_needed(
616
 
                srv_log_group_home_dirs[k]);
617
 
 
618
 
        ut_a(strlen(srv_log_group_home_dirs[k])
619
 
             < (sizeof name) - 10 - sizeof "ib_logfile");
620
 
        sprintf(name, "%s%s%lu", srv_log_group_home_dirs[k],
621
 
                "ib_logfile", (ulong) i);
 
596
 
 
597
        dirnamelen = strlen(srv_log_group_home_dirs[k]);
 
598
        ut_a(dirnamelen < (sizeof name) - 10 - sizeof "ib_logfile");
 
599
        memcpy(name, srv_log_group_home_dirs[k], dirnamelen);
 
600
 
 
601
        /* Add a path separator if needed. */
 
602
        if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
 
603
                name[dirnamelen++] = SRV_PATH_SEPARATOR;
 
604
        }
 
605
 
 
606
        sprintf(name + dirnamelen, "%s%lu", "ib_logfile", (ulong) i);
622
607
 
623
608
        files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_NORMAL,
624
609
                                  OS_LOG_FILE, &ret);
781
766
        *create_new_db = FALSE;
782
767
 
783
768
        srv_normalize_path_for_win(srv_data_home);
784
 
        srv_data_home = srv_add_path_separator_if_needed(srv_data_home);
785
769
 
786
770
        for (i = 0; i < srv_n_data_files; i++) {
 
771
                ulint   dirnamelen;
 
772
 
787
773
                srv_normalize_path_for_win(srv_data_file_names[i]);
 
774
                dirnamelen = strlen(srv_data_home);
788
775
 
789
 
                ut_a(strlen(srv_data_home) + strlen(srv_data_file_names[i])
 
776
                ut_a(dirnamelen + strlen(srv_data_file_names[i])
790
777
                     < (sizeof name) - 1);
791
 
                sprintf(name, "%s%s", srv_data_home, srv_data_file_names[i]);
 
778
                memcpy(name, srv_data_home, dirnamelen);
 
779
                /* Add a path separator if needed. */
 
780
                if (dirnamelen && name[dirnamelen - 1] != SRV_PATH_SEPARATOR) {
 
781
                        name[dirnamelen++] = SRV_PATH_SEPARATOR;
 
782
                }
 
783
 
 
784
                strcpy(name + dirnamelen, srv_data_file_names[i]);
792
785
 
793
786
                if (srv_data_file_is_raw_partition[i] == 0) {
794
787
 
1010
1003
        return(DB_SUCCESS);
1011
1004
}
1012
1005
 
1013
 
/****************************************************************//**
 
1006
/********************************************************************
1014
1007
Starts InnoDB and creates a new database if database files
1015
1008
are not found and the user wants.
1016
1009
@return DB_SUCCESS or error code */
1098
1091
                "InnoDB: !!!!!!!! UNIV_SEARCH_DEBUG switched on !!!!!!!!!\n");
1099
1092
#endif
1100
1093
 
 
1094
#ifdef UNIV_LOG_LSN_DEBUG
 
1095
        fprintf(stderr,
 
1096
                "InnoDB: !!!!!!!! UNIV_LOG_LSN_DEBUG switched on !!!!!!!!!\n");
 
1097
#endif /* UNIV_LOG_LSN_DEBUG */
1101
1098
#ifdef UNIV_MEM_DEBUG
1102
1099
        fprintf(stderr,
1103
1100
                "InnoDB: !!!!!!!! UNIV_MEM_DEBUG switched on !!!!!!!!!\n");
1108
1105
                        "InnoDB: The InnoDB memory heap is disabled\n");
1109
1106
        }
1110
1107
 
1111
 
#ifdef HAVE_GCC_ATOMIC_BUILTINS
1112
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1113
 
        fprintf(stderr,
1114
 
                "InnoDB: Mutexes and rw_locks use GCC atomic builtins.\n");
1115
 
# else /* INNODB_RW_LOCKS_USE_ATOMICS */
1116
 
        fprintf(stderr,
1117
 
                "InnoDB: Mutexes use GCC atomic builtins, rw_locks do not.\n");
1118
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1119
 
#elif defined(HAVE_SOLARIS_ATOMICS)
1120
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1121
 
        fprintf(stderr,
1122
 
                "InnoDB: Mutexes and rw_locks use Solaris atomic functions.\n");
1123
 
# else
1124
 
        fprintf(stderr,
1125
 
                "InnoDB: Mutexes use Solaris atomic functions.\n");
1126
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1127
 
#elif defined(HAVE_WINDOWS_ATOMICS)
1128
 
# ifdef INNODB_RW_LOCKS_USE_ATOMICS
1129
 
        fprintf(stderr,
1130
 
                "InnoDB: Mutexes and rw_locks use Windows interlocked functions.\n");
1131
 
# else
1132
 
        fprintf(stderr,
1133
 
                "InnoDB: Mutexes use Windows interlocked functions.\n");
1134
 
# endif /* INNODB_RW_LOCKS_USE_ATOMICS */
1135
 
#else /* HAVE_GCC_ATOMIC_BUILTINS */
1136
 
        fprintf(stderr,
1137
 
                "InnoDB: Neither mutexes nor rw_locks use GCC atomic builtins.\n");
1138
 
#endif /* HAVE_GCC_ATOMIC_BUILTINS */
 
1108
        fprintf(stderr, "InnoDB: %s\n", IB_ATOMICS_STARTUP_MSG);
1139
1109
 
1140
1110
        /* Since InnoDB does not currently clean up all its internal data
1141
1111
        structures in MySQL Embedded Server Library server_end(), we
1144
1114
 
1145
1115
        if (srv_start_has_been_called) {
1146
1116
                fprintf(stderr,
1147
 
                        "InnoDB: Error:startup called second time"
 
1117
                        "InnoDB: Error: startup called second time"
1148
1118
                        " during the process lifetime.\n"
1149
1119
                        "InnoDB: In the MySQL Embedded Server Library"
1150
1120
                        " you cannot call server_init()\n"
1394
1364
                sum_of_new_sizes += srv_data_file_sizes[i];
1395
1365
        }
1396
1366
 
1397
 
        if (sum_of_new_sizes < 640) {
 
1367
        if (sum_of_new_sizes < 10485760 / UNIV_PAGE_SIZE) {
1398
1368
                fprintf(stderr,
1399
1369
                        "InnoDB: Error: tablespace size must be"
1400
1370
                        " at least 10 MB\n");
1977
1947
                        /* All the threads have exited or are just exiting;
1978
1948
                        NOTE that the threads may not have completed their
1979
1949
                        exit yet. Should we use pthread_join() to make sure
1980
 
                        they have exited? Now we just sleep 0.1 seconds and
1981
 
                        hope that is enough! */
 
1950
                        they have exited? If we did, we would have to
 
1951
                        remove the pthread_detach() from
 
1952
                        os_thread_exit().  Now we just sleep 0.1
 
1953
                        seconds and hope that is enough! */
1982
1954
 
1983
1955
                        os_mutex_exit(os_sync_mutex);
1984
1956
 
2017
1989
                srv_misc_tmpfile = 0;
2018
1990
        }
2019
1991
 
 
1992
        /* This must be disabled before closing the buffer pool
 
1993
        and closing the data dictionary.  */
 
1994
        btr_search_disable();
 
1995
 
 
1996
        ibuf_close();
 
1997
        log_shutdown();
 
1998
        lock_sys_close();
 
1999
        thr_local_close();
2020
2000
        trx_sys_file_format_close();
 
2001
        trx_sys_close();
2021
2002
 
2022
2003
        mutex_free(&srv_monitor_file_mutex);
2023
2004
        mutex_free(&srv_dict_tmpfile_mutex);
2024
2005
        mutex_free(&srv_misc_tmpfile_mutex);
 
2006
        dict_close();
 
2007
        btr_search_sys_free();
2025
2008
 
2026
2009
        /* 3. Free all InnoDB's own mutexes and the os_fast_mutexes inside
2027
2010
        them */
 
2011
        os_aio_free();
2028
2012
        sync_close();
 
2013
        srv_free();
 
2014
        fil_close();
2029
2015
 
2030
2016
        /* 4. Free the os_conc_mutex and all os_events and os_mutexes */
2031
2017
 
2032
 
        srv_free();
2033
2018
        os_sync_free();
2034
2019
 
2035
 
        /* Check that all read views are closed except read view owned
2036
 
        by a purge. */
2037
 
 
2038
 
        if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) {
2039
 
                fprintf(stderr,
2040
 
                        "InnoDB: Error: all read views were not closed"
2041
 
                        " before shutdown:\n"
2042
 
                        "InnoDB: %lu read views open \n",
2043
 
                        UT_LIST_GET_LEN(trx_sys->view_list) - 1);
2044
 
        }
2045
 
 
2046
 
        /* 5. Free all allocated memory and the os_fast_mutex created in
2047
 
        ut0mem.c */
2048
 
 
 
2020
        /* 5. Free all allocated memory */
 
2021
 
 
2022
        pars_lexer_close();
 
2023
        log_mem_free();
2049
2024
        buf_pool_free();
2050
2025
        ut_free_all_mem();
 
2026
        mem_close();
2051
2027
 
2052
2028
        if (os_thread_count != 0
2053
2029
            || os_event_count != 0
2078
2054
        }
2079
2055
 
2080
2056
        srv_was_started = FALSE;
 
2057
        srv_start_has_been_called = FALSE;
2081
2058
 
2082
2059
        return((int) DB_SUCCESS);
2083
2060
}