31 Commits

Author SHA1 Message Date
Markus Makela
7c988c4fd5 Removed stdout specific functions in skygw_utils and moved the logic to log_manager instead. 2015-04-30 04:26:48 +03:00
Markus Makela
47e5b12eb8 Added a function that frees the skygw_file_t memory but doesn't close it. 2015-04-29 18:25:35 +03:00
Markus Makela
9ce225c2cb Added log manager initialization flag that prints all logs to stdout. 2015-04-29 11:20:40 +03:00
Markus Makela
051d891680 Added utility functions to skygw_utils and cleaned up tee filter. 2015-04-15 12:42:28 +03:00
Markus Makela
880adca73e Merge branch 'develop' into MAX-324 2015-03-05 10:45:48 +02:00
Markus Makela
ad49c5f402 Added optional millisecond precision to logfiles and created the changelog document. 2015-02-24 18:10:16 +02:00
Markus Makela
fc969acc73 Added optional stripping of escape characters from database names when laoding users. 2015-02-20 21:07:12 +02:00
Markus Makela
3924f70d6b Fixed log manager sometimes not writing the last character in a log message.
This was caused by type conversions from int to size_t and the usage of the MAX macro.
2015-02-20 04:42:02 +02:00
Markus Makela
ba009e5fd3 Fixes to Coverity defects 85010 84878 72752 72742 72719 and 73418.
skygw_utils.cc: Added function is_valid_posix_path that checks if a path is POSIX-compliant.
2015-01-05 06:05:56 +02:00
VilhoRaatikka
780733f870 MAX-325, Log rotation functionality. When skygw_log_rotate is called, corresponding logfile's rotate flag (lf_rotateflag) is set and log writer thread is woken up. Writer opens a new log file and closes the old one. 2014-11-12 14:48:17 +02:00
VilhoRaatikka
d1772e300e Addition to fix to bug #613, http://bugs.skysql.com/show_bug.cgi?id=613
Added new declaration of skygw_file_write and modification to the function which returns errno instead of boolean.
2014-11-10 13:59:55 +02:00
VilhoRaatikka
726ab87f4b Fix to #575, http://bugs.mariadb.com/show_bug.cgi?id=575
log_manager.cc:
	Log manager handles cases where there are mismatch in user privileges.
	Mark log files enabled in the global lm_enabled_logfiles_bitmask after initialization so that it reflects reality in error cases. In general, take into account the possibility that any phase in initialization may fail and read return values.
	Replaced file_exists_and_is_writable to check_file_and_path which has a slightly different logic and which detects if file open fails for a few different reasons.
	Improved logging (in stderr) in general in error cases.

gateway.c: Also check home directory accessibility in case when it is provided as a command-line argument. Added function check_dir_access to provide that function. Read return value of skysql_logmanager_init and exit (nicely) if it failed.

skygw_utils.cc: initialize mlist with version number 2, which indicates that object is initialized (different than zero) and that there are no active updates on the object (version%2==0).
2014-10-14 13:22:16 +03:00
VilhoRaatikka
cd0c17676e get_decimal_len wasn't declared in C portion of the code and the symbol was mangled. 2014-10-01 22:17:43 +03:00
VilhoRaatikka
686d28a1f0 Fix to bug #506, http://bugs.skysql.com/show_bug.cgi?id=506
If debug and/or trace log is stored to shared memory, the absolute path to file is now /dev/shm/<pid>/skygw_[trace1|debug1].log
2014-09-29 13:21:26 +03:00
VilhoRaatikka
f74493d922 server/modules/filter/Makefile: Fixed problem which prevented cleaning and compiling hintfilter library.
server/core/config.c: Removed unused if..else block from config_get_valint. Changed it also to return value which indicates whether the operation succeed. Added config_get_valbool similar to config_get_valint.
service.c:Added typelib-like struct and array of valid boolean values. Fixed parameter type test in service_set_param_value. Completed boolean type parameter handling.
hintparser.c:Fixed error message for non-maxscale hints.
readwritesplit.c:Added loading of configuration parameters from service to instance and from instance to each new session. Fixed routing condition in get_route_target. Modified get_route_target so that it takes also rw_read_sesvars_from_slaves and rw_write_sesvars_to_all as parameters.
skygw_types.h: added array size counting macro.
2014-09-08 21:44:23 +03:00
VilhoRaatikka
fa2189373d query_classifier.cc: query_is_parsed is now global function and can be used to check whether parsing information already exists in the buffer.
skygw_utils.cc: removed replace_str and implemented replace_literal which replaces user-provided literals in query with predefined string "?". Replacing is done one by one, so it is suboptimal ipmlementation since all literals could be passed to replacement function in one call and processed all before returning.
2014-08-21 22:28:23 +03:00
VilhoRaatikka
544e64a301 query_classifier: implemented skygw_get_canonical which returns a copy of original string with given substrings being replaced with questionmarks.
skygw_utils.cc: added string replacement function for use of skygw_get_canonical
2014-08-18 14:19:46 +03:00
vraatikka
41298a09df Bugzilla entry # 363:
skygw_thread_t and simple_mutex_t make own copy of name argrument. Changed init calls to both accordingly.
2013-11-27 10:51:45 +02:00
vraatikka
9ba7a0d955 log_manager.cc
Added new argument '-s' which takes additional argument composed of list of logfile identifiers. Logfiles listed with '-s' will be written on main memory instead of disk. In practice, the log file in question will be written in /dev/shm but corresponding symlink is added to log directory. In the case of name conflicts with log files and links, a differentiating sequence number is included in hte name of the file. This, however, is done only when existing file is not writable or is of different type (symlink <> file). 
	Added new logfile LOGFILE_DEBUG whose contents will be largerly what was included up to date in trace log. 

	Disabled feature which spreads writes to log files to others because of bug (#338) in the way block buffers are managed.

	Changed log manager parameters to match with the current implementation. List of arguments:
                "-h - help\n"
                "-a <debug prefix>   ............(\"skygw_debug\")\n"
                "-b <debug suffix>   ............(\".log\")\n"
                "-c <trace prefix>   ............(\"skygw_trace\")\n"
                "-d <trace suffix>   ............(\".log\")\n"
                "-e <message prefix> ............(\"skygw_msg\")\n"
                "-f <message suffix> ............(\".log\")\n"
                "-g <error prefix>   ............(\"skygw_err\")\n"
                "-i <error suffix>   ............(\".log\")\n"
                "-j <log path>       ............(\"/tmp\")\n"
                "-s <shmem log file ids> ........(no default)\n";

dcb.c
	dcb_add_to_zombieslist, add dcb to the front of zombies list instead of inserting to the end of it.

gateway.c
	Renamed shutdown_gateway to shutdown_server (Bug #131)
	Call skygw_logmanager_init so that trace and debug logs are written to shared memory.

poll.c 
dcb.h
	Removed some dead code and references to unneeded mutexes.

debugcmd.c
	Added enable/disable log command for debug log.

skygw_utils.cc
	skygw_file_init now takes optional symlink name as a second argument. Symlink is created to point to the file being created.
2013-11-08 12:56:39 +02:00
vraatikka
4360ae16b8 Moved timestamp string creation to skygw_utils where it can be provide service for others too. 2013-08-12 13:09:29 +03:00
vraatikka
52564314d4 Documented concurrency control between filewriter thread and log clients.
Changed log header text, replaced SkySQL GAteway with SkySQL MaxScale.
Fixed bug in log flushing. skygw_log_write_flush didn't cause call of fsync, which suspended file writing.
2013-07-25 16:21:13 +03:00
Mark Riddoch
521a66f9c1 Fix for redefinition of MIN and MAX macros 2013-07-23 13:19:36 +02:00
vraatikka
baed0e846f Changed log_manager to use block-siuze buffers instead of small write buffers. Added new test cases and added iterations. Added possibility to test with dummy disk write which sleeps constantly for 5ms instead of performing disk write. 2013-07-23 08:34:43 +03:00
vraatikka
d11741130d Changed log manager API to support variable length formatted log strings. New API is as follows:
/** No change in these */
bool skygw_logmanager_init(void** buf, int argc, char* argv[]);
void skygw_logmanager_done(void** buf);
void skygw_logmanager_exit(void);
int  skygw_log_flush(logfile_id_t id);

/** writebuf remains unused, but formatted string is now possible and in case 
 * of formatted string, arbitrary long argument list is supported too. Max 
 * length for a log string is defined to BUFSIZ, whose value depends on the 
 * system but typically is 4/8KB.
 */
int  skygw_log_write(void* writebuf, logfile_id_t id, char* format, ...);
int  skygw_log_write_flush(void* writebuf, logfile_id_t id, char* format, ...);

makefile.inc includes new CFLAG : SS_PROF, which is set if PROF=Y on make command line or in build_gateway.inc .
ss_debug.h includes corresponding ss_prof(exp) macro which equals to exp if SS_PROF is defined and to empty if in other case.

mlist_t now includes datadel function which is a callback and it is executed for mlnode_data on node exit.
2013-07-02 14:46:39 +03:00
vraatikka
89a744c8e5 Removed double typedef 2013-06-28 10:23:30 +03:00
vraatikka
1b764eba74 Little fixes 2013-06-27 23:33:20 +03:00
vraatikka
9630ae588e Fixed bugs and cleaned code 2013-06-27 12:18:25 +03:00
vraatikka
ef1d198654 Changed log manager API so that pointer reference to logmanager is not used anymore. Every call initializes logmanager now except skygw_logmanager_done and skygw_log_flush.
skygw_logmanager_init is still useful because it allows for providing memory address for log manager where it can store a list of preallocated write buffers. TBD.

Logmanager access is now protected with spinlock familiar from epoll/core/spinlock.c . It is modified to avoid trashing; misses are counted and every tenth subsequent lock acquiring attempt triggers short random sleep.
2013-06-26 23:13:40 +03:00
vraatikka
8178e4e239 New, yet primitive version of log writing functionality. Fixed some things in utils. 2013-06-25 21:14:03 +03:00
vraatikka
a7229a6c24 Separated libmysqld from list of libs which is used in every link command line. 2013-06-18 21:28:06 +03:00
vraatikka
81bb5bdde8 Adding this too under skygateway 2013-06-17 18:32:01 +03:00