⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srv0srv.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************The database server main programNOTE: SQL Server 7 uses something which the documentationcalls user mode scheduled threads (UMS threads). One suchthread is usually allocated per processor. Win32documentation does not know any UMS threads, which suggeststhat the concept is internal to SQL Server 7. It may mean thatSQL Server 7 does all the scheduling of threads itself, evenin i/o waits. We should maybe modify InnoDB to use the sametechnique, because thread switches within NT may be too slow.SQL Server 7 also mentions fibers, which are cooperativelyscheduled threads. They can boost performance by 5 %,according to the Delaney and Soukup's book.Windows 2000 will have something called thread pooling(see msdn website), which we could possibly use.Another possibility could be to use some very fast user spacethread library. This might confuse NT though.(c) 1995 Innobase OyCreated 10/8/1995 Heikki Tuuri*******************************************************//* Dummy comment */#include "srv0srv.h"#include "ut0mem.h"#include "os0proc.h"#include "mem0mem.h"#include "mem0pool.h"#include "sync0sync.h"#include "thr0loc.h"#include "que0que.h"#include "srv0que.h"#include "log0recv.h"#include "pars0pars.h"#include "usr0sess.h"#include "lock0lock.h"#include "trx0purge.h"#include "ibuf0ibuf.h"#include "buf0flu.h"#include "btr0sea.h"#include "dict0load.h"#include "dict0boot.h"#include "srv0start.h"#include "row0mysql.h"/* This is set to TRUE if the MySQL user has set it in MySQL; currentlyaffects only FOREIGN KEY definition parsing */ibool	srv_lower_case_table_names	= FALSE;/* The following counter is incremented whenever there is some user activityin the server */ulint	srv_activity_count	= 0;/* The following is the maximum allowed duration of a lock wait. */ulint	srv_fatal_semaphore_wait_threshold = 600;/* How much data manipulation language (DML) statements need to be delayed,in microseconds, in order to reduce the lagging of the purge thread. */ulint	srv_dml_needed_delay = 0;ibool	srv_lock_timeout_and_monitor_active = FALSE;ibool	srv_error_monitor_active = FALSE;const char*	srv_main_thread_op_info = "";/* Server parameters which are read from the initfile *//* The following three are dir paths which are catenated before filenames, where the file name itself may also contain a path */char*	srv_data_home 	= NULL;#ifdef UNIV_LOG_ARCHIVEchar*	srv_arch_dir 	= NULL;#endif /* UNIV_LOG_ARCHIVE */ibool	srv_file_per_table = FALSE;	/* store to its own file each table					created by an user; data dictionary					tables are in the system tablespace					0 */ibool   srv_locks_unsafe_for_binlog = FALSE; /* Place locks to records only                                                 i.e. do not use next-key locking                                                except on duplicate key checking and                                                foreign key checking */ulint	srv_n_data_files = 0;char**	srv_data_file_names = NULL;ulint*	srv_data_file_sizes = NULL;	/* size in database pages */ ibool	srv_auto_extend_last_data_file	= FALSE; /* if TRUE, then we						 auto-extend the last data						 file */ulint	srv_last_file_size_max	= 0;		 /* if != 0, this tells						 the max size auto-extending						 may increase the last data						 file size */ulong	srv_auto_extend_increment = 8;		 /* If the last data file is						 auto-extended, we add this						 many pages to it at a time */ulint*  srv_data_file_is_raw_partition = NULL;/* If the following is TRUE we do not allow inserts etc. This protectsthe user from forgetting the 'newraw' keyword to my.cnf */ibool	srv_created_new_raw	= FALSE;char**	srv_log_group_home_dirs = NULL; ulint	srv_n_log_groups	= ULINT_MAX;ulint	srv_n_log_files		= ULINT_MAX;ulint	srv_log_file_size	= ULINT_MAX;	/* size in database pages */ ulint	srv_log_buffer_size	= ULINT_MAX;	/* size in database pages */ ulong	srv_flush_log_at_trx_commit = 1;byte	srv_latin1_ordering[256]	/* The sort order table of the latin1					character set. The following table is					the MySQL order as of Feb 10th, 2002 */= {  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 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 0x49, 0x49, 0x49, 0x49, 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x5D, 0xF7, 0xD8, 0x55, 0x55, 0x55, 0x59, 0x59, 0xDE, 0xFF};		ulint	srv_pool_size		= ULINT_MAX;	/* size in pages; MySQL inits						this to size in kilobytes but						we normalize this to pages in						srv_boot() */ulint	srv_awe_window_size 	= 0;		/* size in pages; MySQL inits						this to bytes, but we						normalize it to pages in						srv_boot() */ulint	srv_mem_pool_size	= ULINT_MAX;	/* size in bytes */ ulint	srv_lock_table_size	= ULINT_MAX;ulint	srv_n_file_io_threads	= ULINT_MAX;#ifdef UNIV_LOG_ARCHIVEibool	srv_log_archive_on	= FALSE;ibool	srv_archive_recovery	= 0;dulint	srv_archive_recovery_limit_lsn;#endif /* UNIV_LOG_ARCHIVE */ulint	srv_lock_wait_timeout	= 1024 * 1024 * 1024;char*   srv_file_flush_method_str = NULL;ulint   srv_unix_file_flush_method = SRV_UNIX_FDATASYNC;ulint   srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;ulint	srv_max_n_open_files	  = 300;/* The InnoDB main thread tries to keep the ratio of modified pagesin the buffer pool to all database pages in the buffer pool smaller thanthe following number. But it is not guaranteed that the value stays belowthat during a time of heavy update/insert activity. */ulong	srv_max_buf_pool_modified_pct	= 90;/* variable counts amount of data read in total (in bytes) */ulint srv_data_read = 0;/* here we count the amount of data written in total (in bytes) */ulint srv_data_written = 0;/* the number of the log write requests done */ulint srv_log_write_requests = 0;/* the number of physical writes to the log performed */ulint srv_log_writes = 0;/* amount of data written to the log files in bytes */ulint srv_os_log_written = 0;/* amount of writes being done to the log files */ulint srv_os_log_pending_writes = 0;/* we increase this counter, when there we don't have enough space in thelog buffer and have to flush it */ulint srv_log_waits = 0;/* this variable counts the amount of times, when the doublewrite bufferwas flushed */ulint srv_dblwr_writes = 0;/* here we store the number of pages that have been flushed to thedoublewrite buffer */ulint srv_dblwr_pages_written = 0;/* in this variable we store the number of write requests issued */ulint srv_buf_pool_write_requests = 0;/* here we store the number of times when we had to wait for a free pagein the buffer pool. It happens when the buffer pool is full and we needto make a flush, in order to be able to read or create a page. */ulint srv_buf_pool_wait_free = 0;/* variable to count the number of pages that were written from bufferpool to the disk */ulint srv_buf_pool_flushed = 0;/* variable to count the number of buffer pool reads that led to thereading of a disk page */ulint srv_buf_pool_reads = 0;/* variable to count the number of sequential read-aheads */ulint srv_read_ahead_seq = 0;/* variable to count the number of random read-aheads */ulint srv_read_ahead_rnd = 0;/* structure to pass status variables to MySQL */export_struc export_vars;/* If the following is != 0 we do not allow inserts etc. This protectsthe user from forgetting the innodb_force_recovery keyword to my.cnf */ulint	srv_force_recovery	= 0;/*-----------------------*//* We are prepared for a situation that we have this many threads waiting fora semaphore inside InnoDB. innobase_start_or_create_for_mysql() sets thevalue. */ulint   srv_max_n_threads       = 0;/* The following controls how many threads we let inside InnoDB concurrently:threads waiting for locks are not counted into the number because otherwisewe could get a deadlock. MySQL creates a thread for each user session, andsemaphore contention and convoy problems can occur withput this restriction.Value 10 should be good if there are less than 4 processors + 4 disks in thecomputer. Bigger computers need bigger values. Value 0 will disable theconcurrency check. */ulong	srv_thread_concurrency	= 0;ulong   srv_commit_concurrency  = 0;os_fast_mutex_t	srv_conc_mutex;		/* this mutex protects srv_conc data					structures */lint	srv_conc_n_threads	= 0;	/* number of OS threads currently					inside InnoDB; it is not an error					if this drops temporarily below zero					because we do not demand that every					thread increments this, but a thread					waiting for a lock decrements this					temporarily */ulint	srv_conc_n_waiting_threads = 0;	/* number of OS threads waiting in the					FIFO for a permission to enter InnoDB					*/typedef struct srv_conc_slot_struct	srv_conc_slot_t;struct srv_conc_slot_struct{	os_event_t			event;		/* event to wait */	ibool				reserved;	/* TRUE if slot							reserved */	ibool				wait_ended;	/* TRUE when another							thread has already set							the event and the							thread in this slot is							free to proceed; but							reserved may still be							TRUE at that point */	UT_LIST_NODE_T(srv_conc_slot_t)	srv_conc_queue;	/* queue node */};UT_LIST_BASE_NODE_T(srv_conc_slot_t)	srv_conc_queue;	/* queue of threads							waiting to get in */srv_conc_slot_t* srv_conc_slots;			/* array of wait							slots *//* Number of times a thread is allowed to enter InnoDB within the sameSQL query after it has once got the ticket at srv_conc_enter_innodb */#define SRV_FREE_TICKETS_TO_ENTER srv_n_free_tickets_to_enter#define SRV_THREAD_SLEEP_DELAY srv_thread_sleep_delay/*-----------------------*//* If the following is set to 1 then we do not run purge and insert buffermerge to completion before shutdown. If it is set to 2, do not even flush thebuffer pool to data files at the shutdown: we effectively 'crash'InnoDB (but lose no committed transactions). */ulint	srv_fast_shutdown	= 0;/* Generate a innodb_status.<pid> file */ibool	srv_innodb_status	= FALSE;ibool	srv_use_doublewrite_buf	= TRUE;ibool	srv_use_checksums = TRUE;ibool   srv_set_thread_priorities = TRUE;int     srv_query_thread_priority = 0;/* TRUE if the Address Windowing Extensions of Windows are used; then we mustdisable adaptive hash indexes */ibool	srv_use_awe			= FALSE;ibool	srv_use_adaptive_hash_indexes 	= TRUE;/*-------------------------------------------*/ulong	srv_n_spin_wait_rounds	= 20;ulong	srv_n_free_tickets_to_enter = 500;ulong	srv_thread_sleep_delay = 10000;ulint	srv_spin_wait_delay	= 5;ibool	srv_priority_boost	= TRUE;ibool	srv_print_thread_releases	= FALSE;ibool	srv_print_lock_waits		= FALSE;ibool	srv_print_buf_io		= FALSE;ibool	srv_print_log_io		= FALSE;ibool	srv_print_latch_waits		= FALSE;ulint		srv_n_rows_inserted		= 0;ulint		srv_n_rows_updated		= 0;ulint		srv_n_rows_deleted		= 0;ulint		srv_n_rows_read			= 0;static ulint	srv_n_rows_inserted_old		= 0;static ulint	srv_n_rows_updated_old		= 0;static ulint	srv_n_rows_deleted_old		= 0;static ulint	srv_n_rows_read_old		= 0;ulint		srv_n_lock_wait_count		= 0;ulint		srv_n_lock_wait_current_count	= 0;ib_longlong	srv_n_lock_wait_time		= 0;ulint		srv_n_lock_max_wait_time	= 0;/*  Set the following to 0 if you want InnoDB to write messages on  stderr on startup/shutdown*/ibool	srv_print_verbose_log		= TRUE;ibool	srv_print_innodb_monitor	= FALSE;ibool   srv_print_innodb_lock_monitor   = FALSE;ibool   srv_print_innodb_tablespace_monitor = FALSE;ibool   srv_print_innodb_table_monitor = FALSE;/* The parameters below are obsolete: */ibool	srv_print_parsed_sql		= FALSE;ulint	srv_sim_disk_wait_pct		= ULINT_MAX;ulint	srv_sim_disk_wait_len		= ULINT_MAX;ibool	srv_sim_disk_wait_by_yield	= FALSE;ibool	srv_sim_disk_wait_by_wait	= FALSE;ibool	srv_measure_contention	= FALSE;ibool	srv_measure_by_spin	= FALSE;	ibool	srv_test_extra_mutexes	= FALSE;ibool	srv_test_nocache	= FALSE;ibool	srv_test_cache_evict	= FALSE;ibool	srv_test_sync		= FALSE;ulint	srv_test_n_threads	= ULINT_MAX;ulint	srv_test_n_loops	= ULINT_MAX;ulint	srv_test_n_free_rnds	= ULINT_MAX;ulint	srv_test_n_reserved_rnds = ULINT_MAX;ulint	srv_test_array_size	= ULINT_MAX;ulint	srv_test_n_mutexes	= ULINT_MAX;/* Array of English strings describing the current state of ani/o handler thread */const char* srv_io_thread_op_info[SRV_MAX_N_IO_THREADS];const char* srv_io_thread_function[SRV_MAX_N_IO_THREADS];time_t	srv_last_monitor_time;mutex_t	srv_innodb_monitor_mutex;/* Mutex for locking srv_monitor_file */mutex_t	srv_monitor_file_mutex;/* Temporary file for innodb monitor output */FILE*	srv_monitor_file;/* Mutex for locking srv_dict_tmpfile.This mutex has a very high rank; threads reserving it should notbe holding any InnoDB latches. */mutex_t	srv_dict_tmpfile_mutex;/* Temporary file for output from the data dictionary */FILE*	srv_dict_tmpfile;/* Mutex for locking srv_misc_tmpfile.This mutex has a very low rank; threads reserving it should notacquire any further latches or sleep before releasing this one. */mutex_t	srv_misc_tmpfile_mutex;/* Temporary file for miscellanous diagnostic output */FILE*	srv_misc_tmpfile;ulint	srv_main_thread_process_no	= 0;ulint	srv_main_thread_id		= 0;/*	IMPLEMENTATION OF THE SERVER MAIN PROGRAM	=========================================There is the following analogue between this databaseserver and an operating system kernel:DB concept			equivalent OS concept----------			---------------------transaction		--	process;query thread		--	thread;lock			--	semaphore;transaction set tothe rollback state	--	kill signal delivered to a process;kernel			--	kernel;query thread execution:(a) without kernel mutexreserved	 	-- 	process executing in user mode;(b) with kernel mutex reserved			--	process executing in kernel mode;The server is controlled by a master thread which runs at

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -