Mysql down because of chinese language maybe - mysql
MySQL version 5.7.19
Error:
[Fri Sep 15 14:40:25.841726 2017] [:error] [pid 17891] [client 125.39.57.36:56477] PHP Warning: mysqli_query(): (HY000/2013): Lost connection to MySQL server during query in /home/dsh.com/public_html/wp-includes/wp-db.php on line 1877
[Fri Sep 15 14:40:25.867495 2017] [:error] [pid 17891] [client 125.39.57.36:56477] WordPress database error Lost connection to MySQL server during query for query \n\t\t\t\t\tSELECT DISTINCT \n\t\t\t\t\t\ts.id,\n\t\t\t\t\t\ts.name,\n\t\t\t\t\t\ts.context,\n\t\t\t\t\t\tst.status,\n\t\t\t\t\t\ts.gettext_context, \n\t\t\t\t\t\tst.value AS tra,\n\t\t\t\t\t\ts.value AS orig\n\t\t\t\t\tFROM wep_icl_string_pages sp\n\t\t\t\t\tINNER JOIN wep_icl_string_urls su\n\t\t\t\t\t\tON su.id = sp.url_id\n\t\t\t\t\tINNER JOIN wep_icl_strings s\n\t\t\t\t\t\tON s.id = sp.string_id\n\t\t\t\t\tLEFT JOIN wep_icl_string_translations st\n\t\t\t\t\t\tON s.id=st.string_id\n\t\t\t\t\t\t\tAND st.language=su.language\n\t\t\t\t\t\t\tAND s.language!=su.language\n\t\t\t\t\tWHERE (su.language='en' and su.url='/') or (su.language='en' and su.url IS NULL)\n\t\t\t\t\t made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), WP_Locale->__construct, WP_Locale->init, __, translate, apply_filters('gettext'), WP_Hook->apply_filters, call_user_func_array, icl_sw_filters_gettext, icl_translate, WPML_Register_String_Filter->translate_by_name_and_context, WPML_ST_DB_Cache->get_translation, WPML_ST_Page_Translations_Cached_Persist->get_translations_for_page, WPML_ST_Page_Translations_Persist->get_translations_for_page
[Fri Sep 15 14:40:37.146892 2017] [:error] [pid 17884] [client 111.30.137.187:54067] WordPress database error Lost connection to MySQL server during query for query \tSELECT element_id, language_code\n\t\t\t\t\t\tFROM wep_icl_translations\n\t\t\t\t\t\tWHERE trid =\n\t\t\t\t\t\t\t(SELECT trid\n\t\t\t\t\t\t\t FROM wep_icl_translations\n\t\t\t\t\t\t\t WHERE element_type = 'post_page'\n\t\t\t\t\t\t\t AND element_id = (SELECT option_value\n\t\t\t\t\t\t\t\t\t\t\t FROM wep_options\n\t\t\t\t\t\t\t\t\t\t\t WHERE option_name='page_on_front'\n\t\t\t\t\t\t\t\t\t\t\t LIMIT 1))\n\t\t\t\t\t\t made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, WP_Query->parse_query, get_option, apply_filters('pre_option_page_on_front'), WP_Hook->apply_filters, call_user_func_array, SitePress->pre_option_page_on_front, WPML_Pre_Option_Page->get
[Fri Sep 15 14:40:37.163339 2017] [:error] [pid 17886] [client 123.126.118.139:46358] WordPress database error Lost connection to MySQL server during query for query \tSELECT element_id, language_code\n\t\t\t\t\t\tFROM wep_icl_translations\n\t\t\t\t\t\tWHERE trid =\n\t\t\t\t\t\t\t(SELECT trid\n\t\t\t\t\t\t\t FROM wep_icl_translations\n\t\t\t\t\t\t\t WHERE element_type = 'post_page'\n\t\t\t\t\t\t\t AND element_id = (SELECT option_value\n\t\t\t\t\t\t\t\t\t\t\t FROM wep_options\n\t\t\t\t\t\t\t\t\t\t\t WHERE option_name='page_on_front'\n\t\t\t\t\t\t\t\t\t\t\t LIMIT 1))\n\t\t\t\t\t\t made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, WP_Query->parse_query, get_option, apply_filters('pre_option_page_on_front'), WP_Hook->apply_filters, call_user_func_array, SitePress->pre_option_page_on_front, WPML_Pre_Option_Page->get
[Fri Sep 15 14:40:37.163902 2017] [:error] [pid 17885] [client 111.30.131.238:53414] WordPress database error Lost connection to MySQL server during query for query \tSELECT element_id, language_code\n\t\t\t\t\t\tFROM wep_icl_translations\n\t\t\t\t\t\tWHERE trid =\n\t\t\t\t\t\t\t(SELECT trid\n\t\t\t\t\t\t\t FROM wep_icl_translations\n\t\t\t\t\t\t\t WHERE element_type = 'post_page'\n\t\t\t\t\t\t\t AND element_id = (SELECT option_value\n\t\t\t\t\t\t\t\t\t\t\t FROM wep_options\n\t\t\t\t\t\t\t\t\t\t\t WHERE option_name='page_on_front'\n\t\t\t\t\t\t\t\t\t\t\t LIMIT 1))\n\t\t\t\t\t\t made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, WP_Query->parse_query, get_option, apply_filters('pre_option_page_on_front'), WP_Hook->apply_filters, call_user_func_array, SitePress->pre_option_page_on_front, WPML_Pre_Option_Page->get
[Fri Sep 15 14:40:37.164819 2017] [:error] [pid 17887] [client 61.49.56.47:42110] WordPress database error Lost connection to MySQL server during query for query \tSELECT element_id, language_code\n\t\t\t\t\t\tFROM wep_icl_translations\n\t\t\t\t\t\tWHERE trid =\n\t\t\t\t\t\t\t(SELECT trid\n\t\t\t\t\t\t\t FROM wep_icl_translations\n\t\t\t\t\t\t\t WHERE element_type = 'post_page'\n\t\t\t\t\t\t\t AND element_id = (SELECT option_value\n\t\t\t\t\t\t\t\t\t\t\t FROM wep_options\n\t\t\t\t\t\t\t\t\t\t\t WHERE option_name='page_on_front'\n\t\t\t\t\t\t\t\t\t\t\t LIMIT 1))\n\t\t\t\t\t\t made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, WP_Query->parse_query, get_option, apply_filters('pre_option_page_on_front'), WP_Hook->apply_filters, call_user_func_array, SitePress->pre_option_page_on_front, WPML_Pre_Option_Page->get
[Fri Sep 15 14:40:37.248191 2017] [:error] [pid 17907] [client 111.30.141.105:34515] PHP Warning: mysqli_query(): (HY000/2013): Lost connection to MySQL server during query in /home/dsh.com/public_html/wp-includes/wp-db.php on line 1877
[Fri Sep 15 14:40:37.546416 2017] [:error] [pid 17940] [client 111.30.141.104:46769] WordPress database error Lost connection to MySQL server during query for query \n\t\t\t\t\tSELECT DISTINCT \n\t\t\t\t\t\ts.id,\n\t\t\t\t\t\ts.name,\n\t\t\t\t\t\ts.context,\n\t\t\t\t\t\tst.status,\n\t\t\t\t\t\ts.gettext_context, \n\t\t\t\t\t\tst.value AS tra,\n\t\t\t\t\t\ts.value AS orig\n\t\t\t\t\tFROM wep_icl_string_pages sp\n\t\t\t\t\tINNER JOIN wep_icl_string_urls su\n\t\t\t\t\t\tON su.id = sp.url_id\n\t\t\t\t\tINNER JOIN wep_icl_strings s\n\t\t\t\t\t\tON s.id = sp.string_id\n\t\t\t\t\tLEFT JOIN wep_icl_string_translations st\n\t\t\t\t\t\tON s.id=st.string_id\n\t\t\t\t\t\t\tAND st.language=su.language\n\t\t\t\t\t\t\tAND s.language!=su.language\n\t\t\t\t\tWHERE (su.language='en' and su.url='/') or (su.language='en' and su.url IS NULL)\n\t\t\t\t\t made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), WP_Locale->__construct, WP_Locale->init, __, translate, apply_filters('gettext'), WP_Hook->apply_filters, call_user_func_array, icl_sw_filters_gettext, icl_translate, WPML_Register_String_Filter->translate_by_name_and_context, WPML_ST_DB_Cache->get_translation, WPML_ST_Page_Translations_Cached_Persist->get_translations_for_page, WPML_ST_Page_Translations_Persist->get_translations_for_page
[Fri Sep 15 14:40:37.548473 2017] [:error] [pid 17941] [client 112.65.193.15:41552] WordPress\xe6\x95\xb0\xe6\x8d\xae\xe5\xba\x93\xe6\x9f\xa5\xe8\xaf\xa2\n\t\t\t\t\tSELECT DISTINCT \n\t\t\t\t\t\ts.id,\n\t\t\t\t\t\ts.name,\n\t\t\t\t\t\ts.context,\n\t\t\t\t\t\tst.status,\n\t\t\t\t\t\ts.gettext_context, \n\t\t\t\t\t\tst.value AS tra,\n\t\t\t\t\t\ts.value AS orig\n\t\t\t\t\tFROM wep_icl_string_pages sp\n\t\t\t\t\tINNER JOIN wep_icl_string_urls su\n\t\t\t\t\t\tON su.id = sp.url_id\n\t\t\t\t\tINNER JOIN wep_icl_strings s\n\t\t\t\t\t\tON s.id = sp.string_id\n\t\t\t\t\tLEFT JOIN wep_icl_string_translations st\n\t\t\t\t\t\tON s.id=st.string_id\n\t\t\t\t\t\t\tAND st.language=su.language\n\t\t\t\t\t\t\tAND s.language!=su.language\n\t\t\t\t\tWHERE (su.language='zh-hans' and su.url='/zh-hans/custom_events/equis%e9%85%92%e5%90%a7%e9%9a%86%e9%87%8d%e5%bc%80%e5%b9%95') or (su.language='zh-hans' and su.url IS NULL)\n\t\t\t\t\t\xe6\x97\xb6\xe5\x8f\x91\xe7\x94\x9fLost connection to MySQL server during query\xe9\x94\x99\xe8\xaf\xaf\xef\xbc\x8c\xe8\xbf\x99\xe6\x98\xaf\xe7\x94\xb1require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), WP_Locale->__construct, WP_Locale->init, __, translate, apply_filters('gettext'), WP_Hook->apply_filters, call_user_func_array, icl_sw_filters_gettext, icl_translate, WPML_Register_String_Filter->translate_by_name_and_context, WPML_ST_DB_Cache->get_translation, WPML_ST_Page_Translations_Cached_Persist->get_translations_for_page, WPML_ST_Page_Translations_Persist->get_translations_for_page\xe6\x9f\xa5\xe8\xaf\xa2\xe7\x9a\x84\xe3\x80\x82, referer: https://m.sogou.com/web/searchList.jsp?uID=HGHnQBYb1jn6MZnw&v=5&dp=1&e=1427&de=1&pid=sogou-clse-2996962656838a97&w=1278&t=1505457569445&s_t=1505457585463&s_from=result_up&htprequery=equis%E9%85%92%E5%90%A7&keyword=equis%E9%85%92%E5%90%A7&pg=webSearchList&sugct=0&sugri=1&sourceid=sugg&sugoq=equis&sugn=5&suguuid=f4fd7139-d195-45f4-ba59-125c7078ccc8&sugsuv=c7f6d6271727f247197063a73eebad69&sugtime=1505457585502
[Fri Sep 15 14:40:37.699627 2017] [:error] [pid 17907] [client 111.30.141.105:34515] WordPress database error Lost connection to MySQL server during query for query \n\t\t\t\t\tSELECT DISTINCT \n\t\t\t\t\t\ts.id,\n\t\t\t\t\t\ts.name,\n\t\t\t\t\t\ts.context,\n\t\t\t\t\t\tst.status,\n\t\t\t\t\t\ts.gettext_context, \n\t\t\t\t\t\tst.value AS tra,\n\t\t\t\t\t\ts.value AS orig\n\t\t\t\t\tFROM wep_icl_string_pages sp\n\t\t\t\t\tINNER JOIN wep_icl_string_urls su\n\t\t\t\t\t\tON su.id = sp.url_id\n\t\t\t\t\tINNER JOIN wep_icl_strings s\n\t\t\t\t\t\tON s.id = sp.string_id\n\t\t\t\t\tLEFT JOIN wep_icl_string_translations st\n\t\t\t\t\t\tON s.id=st.string_id\n\t\t\t\t\t\t\tAND st.language=su.language\n\t\t\t\t\t\t\tAND s.language!=su.language\n\t\t\t\t\tWHERE (su.language='en' and su.url='/') or (su.language='en' and su.url IS NULL)\n\t\t\t\t\t made by require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), WP_Locale->__construct, WP_Locale->init, __, translate, apply_filters('gettext'), WP_Hook->apply_filters, call_user_func_array, icl_sw_filters_gettext, icl_translate, WPML_Register_String_Filter->translate_by_name_and_context, WPML_ST_DB_Cache->get_translation, WPML_ST_Page_Translations_Cached_Persist->get_translations_for_page, WPML_ST_Page_Translations_Persist->get_translations_for_page
whenever mysql is down this kind of error generates in apache error_log.
can anyone please give advise what is wrong ?
Related
sql exception during reportportal login
Below error I am getting on login : {"errorCode":4003,"message":"You do not have enough permissions. SQL [select "public"."users"."id", "public"."users"."login", "public"."users"."password", "public"."users"."role", "public"."users"."email", "public"."project_user"."project_id", "public"."project_user"."project_role", "public"."project"."name" from "public"."users" left outer join "public"."project_user" on "public"."users"."id" = "public"."project_user"."user_id" left outer join "public"."project" on "public"."project_user"."project_id" = "public"."project"."id" where "public"."users"."login" = ?]; ERROR: relation "public.users" does not exist\n Position: 246"} Postgres db is newly setup & I am not getting initial db script to run as reportportal db is have no tables. Below error I am getting in reportportal api pod ... 105 common frames omitted Caused by: org.quartz.JobPersistenceException: Couldn't retrieve trigger: ERROR: relation "quartz.scheduler_triggers" does not exist Position: 15 at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1538) at org.quartz.impl.jdbcjobstore.JobStoreSupport$12.execute(JobStoreSupport.java:1527) at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:245) at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeWithoutLock(JobStoreSupport.java:3800) at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1524) at org.quartz.core.QuartzScheduler.getTrigger(QuartzScheduler.java:1505) at org.quartz.impl.StdScheduler.getTrigger(StdScheduler.java:508) at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:301) at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:245) at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:505) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ... 115 common frames omitted Caused by: org.postgresql.util.PSQLException: ERROR: relation "quartz.scheduler_triggers" does not exist Position: 15 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2578) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2313) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:331) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:448) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:369) at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159) at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:109) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTrigger(StdJDBCDelegate.java:1761) at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveTrigger(JobStoreSupport.java:1536) ... 126 common frames omitted postgres pod error logs : 2022-06-07 13:05:54.034 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:06:12.336 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:07:21.366 GMT [9106] ERROR: relation "quartz.scheduler_triggers" does not exist at character 15 2022-06-07 13:09:41.232 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:12:48.544 GMT [9599] ERROR: relation "quartz.scheduler_triggers" does not exist at character 15 2022-06-07 13:16:49.031 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:17:49.934 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:18:23.063 GMT [10106] ERROR: relation "quartz.scheduler_triggers" does not exist at character 15 2022-06-07 13:20:11.335 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:21:06.134 GMT [8306] ERROR: relation "public.users" does not exist at character 246 2022-06-07 13:23:57.972 GMT [10613] ERROR: relation "quartz.scheduler_triggers" does not exist at character 1 Any help will be appreciated.
Preventing MySQL From Crashing? “Creeping” Memory Leak [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 3 years ago. Improve this question I set up a fresh 1GB VPS server instance dedicated solely to MySQL. Everything seems to be working great. However, I noticed that mysqld memory usage quickly grows and sort of peaks out at about 700MB (as expected), but then it slowly “creeps” up over the course of 1-2 days. Then when it reaches about 770MB, the process gets killed by OOM Killer and restarts within a few seconds. It’s not a massive downtime, but I would like it to be stable. I am using MySQL version 5.7.21. Here are the variables that I changed from default in the my.cnf file, everything else is set to the defaults. The biggest change is an increase memory to the innodb_buffer_pool_size to 512M: !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/ [mysqld] sql_mode = "NO_ENGINE_SUBSTITUTION" innodb_buffer_pool_size = 384M innodb_log_buffer_size = 2097152 innodb_log_file_size = 20971520 innodb_strict_mode = OFF join_buffer_size = 1048576 key_buffer_size = 88080384 max_connect_errors = 10000 max_connections = 151 myisam_recover_options = "BACKUP,FORCE" performance_schema = 0 read_buffer_size = 1048576 slow_query_log = ON sort_buffer_size = 1048576 sync_binlog = 0 thread_stack = 262144 wait_timeout = 14400 I’m kind of noobish with MySQL administration, so I’m hoping someone with more experience can provide some advice to keeping my MySQL instance a bit more stable on my 1GB instance, OOM Killer strategies and making the database faster/efficient at the same time. EDIT: I added some extra files for additional information: SHOW GLOBAL STATUS: https://pastebin.com/SSVEJrQc SHOW GLOBAL VARIABLES: https://pastebin.com/gV5yGdFR SHOW ENGINE INNODB STATUS: https://pastebin.com/suHwbpiP /var/log/mysql/error.log : https://pastebin.com/cRFGrNTp (combined past couple days) The my.cnf file is shown at the top. I made some changes to it to reduce some of the memory usage, such as dropping the innodb_buffer_pool_size down to 384M instead of 512M. According to "top -c", the memory usage quickly rose to around 550MB and slowly creeped up to about 740M, no crash yet. Also, the server instance has 1GB of RAM, so I'm not sure why MySQL has to crash at around 770M. It's just a fresh install of Ubuntu 16.04 and MySQL, nothing else at all, no apache or php. EDIT: I've included more data, I'm running instance on a Dreamhost DreamCompute cloud server: "top" Results: https://pastebin.com/RNBYMf0b "df -h" results: Filesystem Size Used Avail Use% Mounted on udev 488M 0 488M 0% /dev tmpfs 100M 11M 89M 11% /run /dev/vda1 78G 22G 56G 29% / tmpfs 497M 0 497M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 497M 0 497M 0% /sys/fs/cgroup tmpfs 100M 0 100M 0% /run/user/1000 "iostat -x": https://pastebin.com/xUNu7fEi "mysqltuner": https://pastebin.com/pVC3kN1C I'm seeing a lot of "tmpfs" directories (using RAM)? Is there anything that should or shouldn't be on this list? Also, I've just now updated the my.cnf with the values Wilson Hauck provided and will restart mysqld. Edit: Regarding "ulimit", after reading more about it, I edited /etc/security/limits.conf and added the following: "* - nofile 40000" . Now when I use "sudo sh -c "ulimit -n", it shows 40000 instead of 1024. The "iostat -x" and "mysqltuner" reports were created right after I restarted MySQL because they wouldn't install due to "not enough memory". Thanks Wilson for the mysqltuner suggestion, that looks like a great program. UPDATE: 2/25/2018: With all of the recommended settings set, I had mysql again crash about 10 hours ago. Here are the details from syslog: Feb 25 09:41:52 database kernel: [739566.195215] snapd invoked oom-killer: gfp_mask=0x24201ca, order=0, oom_score_adj=-900 Feb 25 09:41:52 database kernel: [739566.195276] snapd cpuset=/ mems_allowed=0 Feb 25 09:41:52 database kernel: [739566.195310] CPU: 0 PID: 1228 Comm: snapd Not tainted 4.4.0-112-generic #135-Ubuntu Feb 25 09:41:52 database kernel: [739566.195311] Hardware name: OpenStack Foundation OpenStack Nova, BIOS Bochs 01/01/2011 Feb 25 09:41:52 database kernel: [739566.195313] 0000000000000286 245c0a16fc0af5b0 ffff8800000839d8 ffffffff813fc233 Feb 25 09:41:52 database kernel: [739566.195317] ffff880000083b90 ffff88003ae39c00 ffff880000083a48 ffffffff8120dafe Feb 25 09:41:52 database kernel: [739566.195319] ffffffff81cd8367 0000000000000000 ffffffff81e6b1a0 0000000000000206 Feb 25 09:41:52 database kernel: [739566.195321] Call Trace: Feb 25 09:41:52 database kernel: [739566.195361] [<ffffffff813fc233>] dump_stack+0x63/0x90 Feb 25 09:41:52 database kernel: [739566.195375] [<ffffffff8120dafe>] dump_header+0x5a/0x1c5 Feb 25 09:41:52 database kernel: [739566.195383] [<ffffffff811946a2>] oom_kill_process+0x202/0x3c0 Feb 25 09:41:52 database kernel: [739566.195385] [<ffffffff81194ac9>] out_of_memory+0x219/0x460 Feb 25 09:41:52 database kernel: [739566.195394] [<ffffffff8119aad5>] __alloc_pages_slowpath.constprop.88+0x965/0xb00 Feb 25 09:41:52 database kernel: [739566.195396] [<ffffffff8119aef6>] __alloc_pages_nodemask+0x286/0x2a0 Feb 25 09:41:52 database kernel: [739566.195404] [<ffffffff811e483c>] alloc_pages_current+0x8c/0x110 Feb 25 09:41:52 database kernel: [739566.195406] [<ffffffff81190c6b>] __page_cache_alloc+0xab/0xc0 Feb 25 09:41:52 database kernel: [739566.195407] [<ffffffff8119317a>] filemap_fault+0x14a/0x3f0 Feb 25 09:41:52 database kernel: [739566.195418] [<ffffffff812a5d56>] ext4_filemap_fault+0x36/0x50 Feb 25 09:41:52 database kernel: [739566.195419] [<ffffffff811bfe70>] __do_fault+0x50/0xe0 Feb 25 09:41:52 database kernel: [739566.195421] [<ffffffff811c39c2>] handle_mm_fault+0xfa2/0x1820 Feb 25 09:41:52 database kernel: [739566.195433] [<ffffffff810bbc6c>] ? set_next_entity+0x9c/0xb0 Feb 25 09:41:52 database kernel: [739566.195443] [<ffffffff8106b687>] __do_page_fault+0x197/0x400 Feb 25 09:41:52 database kernel: [739566.195445] [<ffffffff8106b957>] trace_do_page_fault+0x37/0xe0 Feb 25 09:41:52 database kernel: [739566.195450] [<ffffffff81063f29>] do_async_page_fault+0x19/0x70 Feb 25 09:41:52 database kernel: [739566.195464] [<ffffffff81849af8>] async_page_fault+0x28/0x30 Feb 25 09:41:52 database kernel: [739566.195465] Mem-Info: Feb 25 09:41:52 database kernel: [739566.195470] active_anon:220242 inactive_anon:1399 isolated_anon:0 Feb 25 09:41:52 database kernel: [739566.195470] active_file:799 inactive_file:1712 isolated_file:0 Feb 25 09:41:52 database kernel: [739566.195470] unevictable:913 dirty:1 writeback:0 unstable:0 Feb 25 09:41:52 database kernel: [739566.195470] slab_reclaimable:5664 slab_unreclaimable:3906 Feb 25 09:41:52 database kernel: [739566.195470] mapped:1931 shmem:2691 pagetables:1544 bounce:0 Feb 25 09:41:52 database kernel: [739566.195470] free:12712 free_pcp:113 free_cma:0 Feb 25 09:41:52 database kernel: [739566.195473] Node 0 DMA free:4548kB min:716kB low:892kB high:1072kB active_anon:5548kB inactive_anon:12kB active_file:1068kB inactive_file:1968kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15992kB managed:15908kB mlocked:0kB dirty:4kB writeback:0kB mapped:808kB shmem:364kB slab_reclaimable:220kB slab_unreclaimable:500kB kernel_stack:368kB pagetables:936kB unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:19320 all_unreclaimable? yes Feb 25 09:41:52 database kernel: [739566.195491] lowmem_reserve[]: 0 958 958 958 958 Feb 25 09:41:52 database kernel: [739566.195495] Node 0 DMA32 free:46300kB min:44336kB low:55420kB high:66504kB active_anon:875420kB inactive_anon:5584kB active_file:2128kB inactive_file:4880kB unevictable:3652kB isolated(anon):0kB isolated(file):0kB present:1032184kB managed:1000192kB mlocked:3652kB dirty:0kB writeback:0kB mapped:6916kB shmem:10400kB slab_reclaimable:22436kB slab_unreclaimable:15124kB kernel_stack:3376kB pagetables:5240kB unstable:0kB bounce:0kB free_pcp:452kB local_pcp:452kB free_cma:0kB writeback_tmp:0kB pages_scanned:42084 all_unreclaimable? yes Feb 25 09:41:52 database kernel: [739566.195502] lowmem_reserve[]: 0 0 0 0 0 Feb 25 09:41:52 database kernel: [739566.195504] Node 0 DMA: 1*4kB (U) 6*8kB (UME) 81*16kB (UME) 32*32kB (UM) 8*64kB (ME) 7*128kB (ME) 3*256kB (UM) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 4548kB Feb 25 09:41:52 database kernel: [739566.195514] Node 0 DMA32: 107*4kB (MEH) 240*8kB (ME) 249*16kB (UMEH) 141*32kB (UMEH) 108*64kB (UMEH) 59*128kB (UMEH) 20*256kB (UMEH) 13*512kB (UME) 9*1024kB (UMH) 0*2048kB 0*4096kB = 46300kB Feb 25 09:41:52 database kernel: [739566.195526] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB Feb 25 09:41:52 database kernel: [739566.195560] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB Feb 25 09:41:52 database kernel: [739566.195561] 5817 total pagecache pages Feb 25 09:41:52 database kernel: [739566.195576] 0 pages in swap cache Feb 25 09:41:52 database kernel: [739566.195581] Swap cache stats: add 0, delete 0, find 0/0 Feb 25 09:41:52 database kernel: [739566.195582] Free swap = 0kB Feb 25 09:41:52 database kernel: [739566.195583] Total swap = 0kB Feb 25 09:41:52 database kernel: [739566.195584] 262044 pages RAM Feb 25 09:41:52 database kernel: [739566.195585] 0 pages HighMem/MovableOnly Feb 25 09:41:52 database kernel: [739566.195585] 8019 pages reserved Feb 25 09:41:52 database kernel: [739566.195586] 0 pages cma reserved Feb 25 09:41:52 database kernel: [739566.195587] 0 pages hwpoisoned Feb 25 09:41:52 database kernel: [739566.195588] [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name Feb 25 09:41:52 database kernel: [739566.195593] [ 348] 0 348 9237 1199 21 3 0 0 systemd-journal Feb 25 09:41:52 database kernel: [739566.195595] [ 451] 0 451 25742 46 17 3 0 0 lvmetad Feb 25 09:41:52 database kernel: [739566.195597] [ 452] 0 452 10744 376 24 3 0 -1000 systemd-udevd Feb 25 09:41:52 database kernel: [739566.195599] [ 550] 100 550 25081 61 19 3 0 0 systemd-timesyn Feb 25 09:41:52 database kernel: [739566.195601] [ 940] 0 940 4030 222 11 3 0 0 dhclient Feb 25 09:41:52 database kernel: [739566.195603] [ 1054] 0 1054 1305 29 8 3 0 0 iscsid Feb 25 09:41:52 database kernel: [739566.195604] [ 1055] 0 1055 1430 877 8 3 0 -17 iscsid Feb 25 09:41:52 database kernel: [739566.195606] [ 1063] 0 1063 68647 1056 37 3 0 0 accounts-daemon Feb 25 09:41:52 database kernel: [739566.195608] [ 1072] 0 1072 6932 491 19 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195609] [ 1078] 0 1078 6511 337 18 3 0 0 atd Feb 25 09:41:52 database kernel: [739566.195611] [ 1091] 0 1091 1099 300 8 3 0 0 acpid Feb 25 09:41:52 database kernel: [739566.195613] [ 1094] 0 1094 7136 99 19 3 0 0 systemd-logind Feb 25 09:41:52 database kernel: [739566.195614] [ 1099] 0 1099 16377 273 35 3 0 -1000 sshd Feb 25 09:41:52 database kernel: [739566.195616] [ 1101] 104 1101 64098 348 27 3 0 0 rsyslogd Feb 25 09:41:52 database kernel: [739566.195618] [ 1105] 107 1105 10722 380 27 3 0 -900 dbus-daemon Feb 25 09:41:52 database kernel: [739566.195619] [ 1113] 0 1113 70365 2590 31 6 0 -900 snapd Feb 25 09:41:52 database kernel: [739566.195621] [ 1114] 0 1114 158952 1017 31 4 0 0 lxcfs Feb 25 09:41:52 database kernel: [739566.195623] [ 1150] 0 1150 3343 36 11 3 0 0 mdadm Feb 25 09:41:52 database kernel: [739566.195624] [ 1159] 0 1159 69294 181 38 3 0 0 polkitd Feb 25 09:41:52 database kernel: [739566.195626] [ 1203] 0 1203 3618 374 12 3 0 0 agetty Feb 25 09:41:52 database kernel: [739566.195627] [13137] 0 13137 3664 356 11 3 0 0 agetty Feb 25 09:41:52 database kernel: [739566.195629] [13141] 0 13141 3664 329 12 3 0 0 agetty Feb 25 09:41:52 database kernel: [739566.195631] [ 4475] 112 4475 345228 190282 441 4 0 0 mysqld Feb 25 09:41:52 database kernel: [739566.195635] [28991] 0 28991 1126 141 8 3 0 0 apt.systemd.dai Feb 25 09:41:52 database kernel: [739566.195638] [28998] 0 28998 1126 383 8 3 0 0 apt.systemd.dai Feb 25 09:41:52 database kernel: [739566.195640] [29036] 0 29036 11324 1282 27 3 0 0 apt-get Feb 25 09:41:52 database kernel: [739566.195641] [29217] 0 29217 11324 867 23 3 0 0 apt-get Feb 25 09:41:52 database kernel: [739566.195643] [29220] 0 29220 1126 157 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195645] [29221] 0 29221 1126 367 9 3 0 0 update-motd-upd Feb 25 09:41:52 database kernel: [739566.195646] [29235] 0 29235 40967 16609 84 3 0 0 apt-check Feb 25 09:41:52 database kernel: [739566.195648] [29570] 0 29570 12235 358 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195649] [29571] 0 29571 1126 144 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195651] [29572] 0 29572 2809 278 10 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195653] [29579] 0 29579 12235 290 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195654] [29580] 0 29580 1126 163 7 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195656] [29581] 0 29581 2809 91 9 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195658] [29582] 0 29582 14775 135 30 3 0 0 sshd Feb 25 09:41:52 database kernel: [739566.195659] [29584] 0 29584 12235 358 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195661] [29589] 0 29589 14775 134 32 3 0 0 sshd Feb 25 09:41:52 database kernel: [739566.195662] [29592] 0 29592 12855 431 30 3 0 0 sudo Feb 25 09:41:52 database kernel: [739566.195664] [29597] 0 29597 1126 70 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195665] [29598] 0 29598 2809 124 9 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195667] [29602] 0 29602 12235 357 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195668] [29603] 0 29603 1126 92 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195670] [29604] 0 29604 2809 321 10 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195672] [29615] 0 29615 5787 36 13 3 0 0 systemctl Feb 25 09:41:52 database kernel: [739566.195673] [29620] 0 29620 12235 276 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195675] [29621] 0 29621 11236 413 26 3 0 0 sudo Feb 25 09:41:52 database kernel: [739566.195677] [29623] 0 29623 1126 139 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195678] [29624] 0 29624 2807 234 10 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195680] [29628] 0 29628 14775 75 30 3 0 0 sshd Feb 25 09:41:52 database kernel: [739566.195681] [29629] 0 29629 12235 476 28 3 0 0 cron Feb 25 09:41:52 database kernel: [739566.195683] [29641] 0 29641 6945 111 18 3 0 0 sudo Feb 25 09:41:52 database kernel: [739566.195684] [29642] 0 29642 6945 87 18 3 0 0 sudo Feb 25 09:41:52 database kernel: [739566.195686] [29643] 0 29643 1126 152 8 3 0 0 sh Feb 25 09:41:52 database kernel: [739566.195687] [29644] 0 29644 345 1 5 3 0 0 bash Feb 25 09:41:52 database kernel: [739566.195689] Out of memory: Kill process 4475 (mysqld) score 750 or sacrifice child Feb 25 09:41:52 database kernel: [739566.197374] Killed process 4475 (mysqld) total-vm:1380912kB, anon-rss:761128kB, file-rss:0kB Feb 25 09:41:53 database kernel: [739566.658202] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20807 DF PROTO=TCP SPT=54168 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739566.658214] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20808 DF PROTO=TCP SPT=49412 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739566.658291] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20809 DF PROTO=TCP SPT=54293 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739566.666146] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20810 DF PROTO=TCP SPT=53588 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739566.666160] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20811 DF PROTO=TCP SPT=53612 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database systemd[1]: Started MySQL Community Server. Feb 25 09:41:53 database CRON[29570]: (CRON) info (No MTA installed, discarding output) Feb 25 09:41:53 database systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL Feb 25 09:41:53 database systemd[1]: mysql.service: Unit entered failed state. Feb 25 09:41:53 database systemd[1]: mysql.service: Failed with result 'signal'. Feb 25 09:41:53 database systemd[1]: mysql.service: Service hold-off time over, scheduling restart. Feb 25 09:41:53 database systemd[1]: Stopped MySQL Community Server. Feb 25 09:41:53 database systemd[1]: Starting MySQL Community Server... Feb 25 09:41:53 database kernel: [739567.046536] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=42 ID=21475 DF PROTO=TCP SPT=37118 DPT=22 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739567.066187] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20869 DF PROTO=TCP SPT=54293 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739567.066313] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20870 DF PROTO=TCP SPT=49412 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739567.066324] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.*** DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20871 DF PROTO=TCP SPT=54168 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:53 database kernel: [739567.082221] [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:bc:28:e3:44:f4:77:a7:c0:20:08:00 SRC=***.***.***.***DST=***.***.***.*** LEN=40 TOS=0x00 PREC=0x00 TTL=61 ID=20873 DF PROTO=TCP SPT=53612 DPT=3306 WINDOW=0 RES=0x00 RST URGP=0 Feb 25 09:41:54 database kernel: [739567.524532] audit: type=1400 audit(1519551714.232:296): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29710/status" pid=29710 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=112 Feb 25 09:41:54 database kernel: [739567.524603] audit: type=1400 audit(1519551714.232:297): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=29710 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=0 Feb 25 09:41:54 database kernel: [739567.524670] audit: type=1400 audit(1519551714.232:298): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29710/status" pid=29710 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=112 Feb 25 09:41:56 database systemd[1]: Started MySQL Community Server. According to MySQLtuner, it says: "Maximum possible memory usage: 664.8M (66.99% of installed RAM)", so it must be exceeding this somehow.
Suggestions to consider for your my.cnf/ini [mysqld] section, ulimit -n 40000 # at your Linux command prompt to raise n open files limit table_open_cache=10000 # from 2000 to support 1M+ opened in 2 days table_definition_cache=2500 # from default to support 2000+ opened in 2 days open_files_limit=30000 # from 5000 to support 900,000 + opened in 2 days max_connections=50 # from 151 to support 17 max_used_connections read_rnd_buffer_size=128K # from 256k default to reduce RD RPS innodb_change_buffer_max_size=15 # from 25% of innodb_buffer_pool_size 1% used innodb_log_buffer_size=12M # from 2M to cover 30 minutes of log innodb_log_file_size=120M # from ~ 20M to cover a few days #max_allowed_packet=16M # lead with # for default of 1M m_a_p if you need more than 1M, in your SESSION SET #max_allowed_packet=nnnnnnnn; up to 1G and 1G is the LIMIT. query_cache_size=0 # from 16M - it is already OFF, do not waste RAM on it query_cache_limit=1K # from 1M to conserve more RAM query_cache_min_res_unit=512 # from 4096 to store more small results, if ever used innodb_buffer_pool_instances=8 # from 1 to minimize mutex contention will be fine with you UNDER 1G per instance of innodb_buffer_pool_size innodb_lru_scan_depth=128 # from 1024 which is causing page_cleaner warnings innodb_page_cleaners=64 # from 1 to auto follow = innodb_buffer_pool_instances thread_cache_size=50 # from 8 default to support 17 max_used with room for growth. from my perspective, backup your current my.cnf/ini and implement all. There are more opportunities for another day. Could we use Stack Overflow's chat next week ?
Your query_cache_size is 52428800 = 50M innodb_buffer_pool_size = 512M key_buffer_size = 88080384 = 84M That's already ~650M, which leaves MySQL about 50M for 'other stuff'. If you tweak down some of these settings, chances are that you can stay below 700M. Unless your version of MySQL really has a memory leak. Try reducing some of these numbers by another 50M in total. Bonus: Just found this calculator: http://www.mysqlcalculator.com/. Might help you figure this out more accurately. Can't speak to how accurate this tool is though
To answer part of your question: Also, the server instance has 1GB of RAM, so I'm not sure why MySQL has to crash at around 770M. It's just a fresh install of Ubuntu 16.04 and MySQL, nothing else at all, no apache or php. A server doesn't have "nothing else at all" even if you don't install anything else yourself, there's always background stuff going on as well, and whatever your VPS image includes. You can use top (or if available my preferred tool, htop) to see what's running and what's using memory. In the OOM kill log, for instance, apt-check has an rss size of 16848, meaning it's taking another 70GB of RAM by itself (see this answer on OOM kiler logs - the numbers indicate 4kB blocks). Additionally, many of the system "directories" such as /tmp are actually stored in RAM rather than on disk. You can see if that's the caes on your machine by running df -h - anything listed with tmpfs as its filesystem is stored in RAM, and if it has space being used, is using RAM as well. Put various things together, and it's plausible that various system processes can take a decent chunk of that RAM overhead, even without any other processes you specifically installed.
Error in executing dynamic SQL Query with table variable in SQL Server 2008
These are the following parameters & table variable used for executing dynamic sql query: Declaration DECLARE #sQuery VARCHAR(MAX) DECLARE #FYear NVARCHAR(10)='2016-2017' DECLARE #TYear NVARCHAR(10)='2016-2018' DECLARE #CLAIMSUM TABLE ( ClaimType NVARCHAR(MAX), JAN DECIMAL(19,6), FEB DECIMAL(19,6), MAR DECIMAL(19,6), APR DECIMAL(19,6), MAY DECIMAL(19,6), JUN DECIMAL(19,6), JUL DECIMAL(19,6), AUG DECIMAL(19,6), SEP DECIMAL(19,6), OCT DECIMAL(19,6), NOV DECIMAL(19,6), DEC DECIMAL(19,6), TOTAL DECIMAL(19,6) ) Dynamic SQL Query SET #sQuery=N'SELECT C1.ClaimType, SUM(C1.JAN) AS ''JAN '+#FYear+'-'+#TYear+''',SUM(C1.FEB) AS ''FEB '+#FYear+'-'+#TYear+''',SUM(C1.MAR) AS ''MAR '+#FYear+'-'+#TYear+''', SUM(C1.APR) AS ''APR '+#FYear+'-'+#TYear+''',SUM(C1.MAY) AS ''MAY '+#FYear+'-'+#TYear+''',SUM(C1.JUN) AS ''JUN '+#FYear+'-'+#TYear+''', SUM(C1.JUL) AS ''JUL '+#FYear+'-'+#TYear+''',SUM(C1.AUG) AS ''AUG '+#FYear+'-'+#TYear+''',SUM(C1.SEP) AS ''SEP '+#FYear+'-'+#TYear+''', SUM(C1.OCT) AS ''OCT '+#FYear+'-'+#TYear+''',SUM(C1.NOV) AS ''NOV '+#FYear+'-'+#TYear+''',SUM(C1.DEC) AS ''DEC '+#FYear+'-'+#TYear+''', SUM(C1.TOTAL) AS ''TOTAL'' FROM #CLAIMSUM C1 GROUP BY C1.ClaimType'; EXECUTE #sQuery Error When executing this query I am getting following error: The name 'SELECT C1.ClaimType, SUM(C1.JAN) AS 'JAN 2016-2017',SUM(C1.FEB) AS 'FEB 2016-2017',SUM(C1.MAR) AS 'MAR 2016-2017', SUM(C1.APR) AS 'APR 2016-2017',SUM(C1.MAY) AS 'MAY 2016-2017',SUM(C1.JUN) AS 'JUN 2016-2017', SUM(C1.JUL) AS 'JUL 2016-2017',SUM(C1.AUG) AS 'AUG 2016-2017',SUM(C1.SEP) AS 'SEP 2016-2017', SUM(C1.OCT) AS 'OCT 2016-2017',SUM(C1.NOV) AS 'NOV 2016-2017',SUM(C1.DEC) AS 'DEC 2016-2017', SUM(C1.TOTAL) AS 'TOTAL' FROM #CLAIMSUM C1 GROUP BY C1.ClaimType' is not a valid identifier.
I had replaced EXECUTE #sQuery with EXECUTE (#sQuery) and now it is working fine.
To get values from 2D array
I have used this query to retrieve the dates for one particular user's approved leaves - LeaveRequest.where(user_id: 6).where(status: 1).pluck(:from_date, :to_date) and I'm getting this array as result - [[Mon, 12 Sep 2016, Fri, 16 Sep 2016], [Tue, 06 Sep 2016, Tue, 06 Sep 2016], [Thu, 01 Sep 2016, Fri, 02 Sep 2016], [Tue, 30 Aug 2016, Wed, 31 Aug 2016]] what I want is to fetch all the dates as well as the dates between 12 Sep 2016 and 16 Sep, 2016 (13th 14th and 15th).
I am assuming you mean something like this require 'date' #This is to simulate your current Array current_array = 5.times.map {|n [Date.new(2016,n+1,1).<<(1),Date.new(2016,n+1,1)]} #map the 2 dates to a Range new_array = current_array.map{|start_date,end_date| (start_date..end_date)} new_array.first.class #=> Range Calling to_a on the Range will blow it out into all the dates between start_date and end_date With a rails you could do something like class LeaveRequest def self.user_requested_ranges(user_id, status_id) scoped. where(user_id: user_id, status: status_id). pluck(:from_date, :to_date). map do |from_date, to_date| #optionally to output the full Array in each Range you could use #(from_date..to_date).to_a (from_date..to_date) end end end Then call as LeaveRequest.user_requested_ranges(6,1)
logging mysql statements executed by jdbc
I tried to log mysql statements , executed by jdbc , hoping to see strings containing declare some cursor or fetch some cursor. But there was not. Are there any ways to see them? PS i set variables in mysql as following: SET GLOBAL log_output="FILE" SET GLOBAL general_log_file="Path/File" SET GLOBAL general_log='ON'
Try this. Add 'logger' and 'profileSQL' to the jdbc url: &logger=com.mysql.jdbc.log.Slf4JLogger&profileSQL=true Then you will get the SQL statement below: 2016-01-14 10:09:43 INFO MySQL - FETCH created: Thu Jan 14 10:09:43 CST 2016 duration: 1 connection: 19130945 statement: 999 resultset: 0 2016-01-14 10:09:43 INFO MySQL - QUERY created: Thu Jan 14 10:09:43 CST 2016 duration: 1 connection: 19130945 statement: 999 resultset: 0 message: SET sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES' 2016-01-14 10:09:43 INFO MySQL - FETCH created: Thu Jan 14 10:09:43 CST 2016 duration: 1 connection: 19130945 statement: 999 resultset: 0 2016-01-14 10:09:43 INFO MySQL - QUERY created: Thu Jan 14 10:09:43 CST 2016 duration: 2 connection: 19130945 statement: 13 resultset: 17 message: select 1 2016-01-14 10:09:43 INFO MySQL - FETCH created: Thu Jan 14 10:09:43 CST 2016 duration: 0 connection: 19130945 statement: 13 resultset: 17 2016-01-14 10:09:43 INFO MySQL - QUERY created: Thu Jan 14 10:09:43 CST 2016 duration: 1 connection: 19130945 statement: 15 resultset: 18 message: select ##session.tx_read_only 2016-01-14 10:09:43 INFO MySQL - FETCH created: Thu Jan 14 10:09:43 CST 2016 duration: 0 connection: 19130945 statement: 15 resultset: 18 2016-01-14 10:09:43 INFO MySQL - QUERY created: Thu Jan 14 10:09:43 CST 2016 duration: 2 connection: 19130945 statement: 14 resultset: 0 message: update sequence set seq=seq+incr where name='demo' and seq=4602 2016-01-14 10:09:43 INFO MySQL - FETCH created: Thu Jan 14 10:09:43 CST 2016 duration: 0 connection: 19130945 statement: 14 resultset: 0 The default logger is: com.mysql.jdbc.log.StandardLogger Mysql jdbc property list: https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html