Mar
02
2015
--

Silent Circle Outs Blackphone 2, Blackphone+ Tablet As It Zeroes In On Enterprise Security

blackphone2 A sequel to last year’s pro-privacy Android smartphone Blackphone has just been announced, here at the Mobile World Congress trade show in Barcelona, along with a tablet device, called Blackphone+. Read More

Mar
01
2015
--

Two Semiconductor Companies You Haven’t Heard Of Are Merging In A $40B Deal

tech-ipo What is worth $40 billion, and isn’t Uber? The union of NXP Semiconductors, and Freescale Semiconductor. The two companies announced a “definitive agreement” today that will see Freescale shareholders pick up 0.3521 NXP shares and $6.26 in cash for each of their current shares.
Freescale is known for its work in embedded chips, its website noting a focus on the Internet of… Read More

Feb
27
2015
--

3 handy tools to remove problematic MySQL processes

class="alignright wp-image-28849 size-thumbnail" src="http://www.percona.com/blog/wp-content/uploads/2015/02/3-handy-tools-to-remove-problematic-MySQL-processes-150x150.jpg" alt="3 handy tools to remove problematic MySQL processes" width="150" height="150" />DBAs often encounter situations where they need to kill queries to ensure there are no long-running queries on a MySQL server that would impact performance. Long-running queries can be the result of many factors. Fortunately, title="Percona Server" href="http://www.percona.com/software/percona-server" >Percona Server contains some handy tools to remove problematic MySQL processes. I will highlight all of the tools via some examples in this post.

pt-kill: /> There have been some good posts on this blog about the pt-kill tool, like this one by Arunjith Aravindan titled “ href="http://www.percona.com/blog/2014/11/19/how-a-set-of-queries-can-be-killed-in-mysql-using-pt-kill/" >How a set of queries can be killed in MySQL using Percona Toolkit’s pt-kill.” Let’s dive into title="pt-kill" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html" >pt-kill a bit further with a few more examples. What does pt-kill do? It kills MySQL connections. Say you wanted to run pt-kill from a cronjob and then get an email on every killed process/query. Here is typical example for that.

$ pt-kill --interval 1 --run-time 1 --busy-time 5 --log /path/to/kill_long_running_thread.log --match-info "^(select|SELECT|Select)" --kill --print --user=xxxxxx --password=xxxxxxxxxx

Assume this is running from a cronjob, When pt-kill executes, it will kill queries longer than 5 seconds. By default, pt-kill runs forever title="--run-time" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--run-time" >–run-time option tells how long pt-kill to run before exiting If title="--interval" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--interval" >–interval and title="--busy-time" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--busy-time" >–busy-time parameters are used together then the explicit –interval value is used. Otherwise the default interval is 30 seconds. Note: this will only kill all read queries as per the title="--match-info" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--match-info" >–match-info parameter.

The above command will log all killed queries in the file referenced with the title="--log" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--log" >–log option. If you need to be notified via email for every killed query, the command below will do it. Off-course, you need to have the system configured to send e-mail.

#!/bin/bash
tail -n 0 -F /path/to/kill_long_running_thread.log | while read LOG
do
echo "$LOG" | mail -s "pt-kill alert" sample@test.com
done

You can execute this shell script in the background within title="screen" rel="nofollow" href="http://www.computerhope.com/unix/screen.htm" rel="nofollow">screen or with the title="nohup" rel="nofollow" href="http://linux.die.net/man/1/nohup" rel="nofollow">nohup utility continuously to monitor the log file. It will send an email whenever any new killed query arrives to the referenced log file in the pt-kill command. Unfortunately, there is no option to notify-by-email in pt-kill at the moment, so this is sort of a workaround.

In order to log all killed queries into a database table you will need to use the title="--log-dsn" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--log-dsn" >–log-dsn option as per the example below.

$ pt-kill --interval 1 --busy-time 1 --create-log-table --log-dsn=h=localhost,D=percona,t=kill_log --daemonize --match-info "^(select|SELECT|Select)" --kill

All killed queries will be logged into percona.kill_log table. The title="--daemonize" href="http://www.percona.com/doc/percona-toolkit/2.2/pt-kill.html#cmdoption-pt-kill--daemonize" >–daemonize option will run this command in the background forever and will kill all SELECT queries running longer than 1 second (–busy-time 1). The –interval option instructs pt-kill to scan processes every 1 second (–interval 1).

mysql> select * from kill_log;
+---------+-----------+---------------------+-------------------------+------------+-------+------+-----------+------+---------+------+------------+-----------------+---------+
| kill_id | server_id | timestamp           | reason                  | kill_error | Id    | User | Host      | db   | Command | Time | State      | Info            | Time_ms |
+---------+-----------+---------------------+-------------------------+------------+-------+------+-----------+------+---------+------+------------+-----------------+---------+
|      17 |         1 | 2015-01-10 08:38:33 | Query matches Info spec |            | 35146 | root | localhost | NULL | Query   |    0 | User sleep | SELECT SLEEP(5) |    NULL |
|      20 |         1 | 2015-01-10 08:38:34 | Query matches Info spec |            | 35223 | root | localhost | NULL | Query   |    0 | User sleep | SELECT SLEEP(5) |    NULL |
+---------+-----------+---------------------+-------------------------+------------+-------+------+-----------+------+---------+------+------------+-----------------+---------+

With the help of logging killed queries into a database tables. You can easily get all the trends/and /statistics on killed queries via SQL.

By default the tool kills the oldest of the queries that would have been running for more than a given –busy-time.  If you need to kill all the threads that have been busy for more than a specified –busy-time, then this will do it:

$ pt-kill --victims=all --busy-time=60

Statement Timeout in Percona Server: /> The max-statement-time feature is ported from the Twitter patches. This feature can be used to limit the query execution time by specifying the timeout value in the class="reference internal" title="max_statement_time" href="http://www.percona.com/doc/percona-server/5.6/management/statement_timeout.html#max_statement_time" > class="xref psdom psdom-variable docutils literal"> class="pre">max_statement_time class="Apple-converted-space"> variable. When the specified number of milliseconds is reached the server class="Apple-converted-space"> aborts the statement and returns the error below to the client. />

ERROR 1877 (70101): Query execution was interrupted, max_statement_time exceeded

Let me demonstrate this through another example:

mysql [localhost] {msandbox} (world) > SET max_statement_time=1;
Query OK, 0 rows affected (0.00 sec)
mysql [localhost] {msandbox} (world) > show variables like 'max_statement_time';
+--------------------+-------+
| Variable_name      | Value |
+--------------------+-------+
| max_statement_time | 1     |
+--------------------+-------+
1 row in set (0.00 sec)
mysql [localhost] {msandbox} (world) > SELECT * FROM City WHERE District = 'abcd';
ERROR 1885 (70101): Query execution was interrupted, max_statement_time exceeded
mysql [localhost] {msandbox} (world) > UPDATE City SET District='abcd' WHERE ID = 2001;
ERROR 1885 (70101): Query execution was interrupted, max_statement_time exceeded
mysql [localhost] {msandbox} (world) > ALTER TABLE City ADD INDEX district_idx (district);
ERROR 1885 (70101): Query execution was interrupted, max_statement_time exceeded

As you can see from this example statement, the timeout feature works for all statements including SELECT/DML/DDL queries.

mysql [localhost] {msandbox} (world) > show status like 'Max_statement%';
+-------------------------------+-------+
| Variable_name                 | Value |
+-------------------------------+-------+
| Max_statement_time_exceeded   | 3     |
| Max_statement_time_set        | 19    |
| Max_statement_time_set_failed | 0     |
+-------------------------------+-------+
3 rows in set (0.00 sec)

The above mentioned status variables are stats for a statement timeout feature. title="Max_statement_time_exceeded" href="http://www.percona.com/doc/percona-server/5.6/management/statement_timeout.html#Max_statement_time_exceeded" >Max_statement_time_exceeded will inform you that the total number of statements exceeded the defined timeout. title="Max_statement_time_set" href="http://www.percona.com/doc/percona-server/5.6/management/statement_timeout.html#Max_statement_time_set" >Max_statement_time_set defines the number of statements for which execution time limit was set. You can find more details in this title="documentation" href="http://www.percona.com/doc/percona-server/5.6/management/statement_timeout.html" >documentation. The statement timeout feature was introduced in Percona Server 5.6. You can check if your specific version of Percona Server supports this feature or not via the title="have_statement_timeout" href="http://www.percona.com/doc/percona-server/5.6/management/statement_timeout.html#have_statement_timeout" >have_statement_timeout variable.

mysql [localhost] {msandbox} (world) > show global variables like 'have_statement_timeout';
+------------------------+-------+
| Variable_name          | Value |
+------------------------+-------+
| have_statement_timeout | YES   |
+------------------------+-------+
1 row in set (0.00 sec)

Bugs you should be aware of:

title="https://bugs.launchpad.net/percona-server/+bug/1388533" rel="nofollow" href="https://bugs.launchpad.net/percona-server/+bug/1388533" rel="nofollow">https://bugs.launchpad.net/percona-server/+bug/1388533 -> This affects how the feature interacts with stored procedures. If you use stored procedures, max_statement_time might not behave as you expect. /> title="https://bugs.launchpad.net/percona-server/+bug/1307432" rel="nofollow" href="https://bugs.launchpad.net/percona-server/+bug/1307432" rel="nofollow">https://bugs.launchpad.net/percona-server/+bug/1307432 -> This is documentation bug. Percona Server timeouts might not be safe for some statements like DDL and should not be used with such queries, The documentation does not reflect this. You should be very careful if you set a global statement timeout, It affects data changing queries as well. For best results set the max_statement_time variable in a session before running queries that you want to be killed if they execute too long, instead of using a global variable. /> title="https://bugs.launchpad.net/percona-server/+bug/1376934" rel="nofollow" href="https://bugs.launchpad.net/percona-server/+bug/1376934" rel="nofollow">https://bugs.launchpad.net/percona-server/+bug/1376934 -> This affects the statement timeout feature on the query level. You must set max_statement_time in a session or globally instead however, this bug is fixed in latest version i.e. class="value" rel="nofollow" href="https://launchpad.net/percona-server/+milestone/5.6.22-72.0" rel="nofollow">Percona Server 5.6.22-72.0

InnoDB Kill Idle Transactions: /> This feature was introduced in Percona Server 5.5. It limits the age of idle XtraDB transactions and will kill idle transactions longer than a specified threshold for title="innodb_kill_idle_transaction" href="http://www.percona.com/doc/percona-server/5.5/management/innodb_kill_idle_trx.html#innodb_kill_idle_transaction" >innodb_kill_idle_transaction. This feature is useful when autocommit is disabled on the server side and you are relying on the application to commit transactions and want to avoid long running transactions that are uncommitted. Application logic errors sometimes leaves transactions uncommitted. Let me demonstrate it quickly through one example:

mysql [localhost] {msandbox} (world) > show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | OFF   |
+---------------+-------+
mysql [localhost] {msandbox} (world) > show global variables like 'innodb_kill_idle_transaction';
+------------------------------+-------+
| Variable_name                | Value |
+------------------------------+-------+
| innodb_kill_idle_transaction | 10    |
+------------------------------+-------+
mysql [localhost] {msandbox} (world) > START TRANSACTION; SELECT NOW(); INSERT INTO City_backup (Name,CountryCode,District,Population) VALUES ('Karachi','PK','Sindh','1000000');
Query OK, 0 rows affected (0.00 sec)
+---------------------+
| NOW()               |
+---------------------+
| 2015-01-31 07:11:39 |
+---------------------+
1 row in set (0.00 sec)
Query OK, 1 row affected (0.01 sec)
mysql [localhost] {msandbox} (world) > SHOW ENGINE INNODB STATUSG
*************************** 1. row ***************************
------------
TRANSACTIONS
------------
---TRANSACTION 173076, ACTIVE 10 sec
1 lock struct(s), heap size 360, 0 row lock(s), undo log entries 1
MySQL thread id 15, OS thread handle 0x7f862e9bf700, query id 176 localhost msandbox init
SHOW ENGINE InnoDB STATUS
TABLE LOCK table `world`.`City_backup` trx id 173076 lock mode IX
----------------------------
END OF INNODB MONITOR OUTPUT
============================
mysql [localhost] {msandbox} (world) > SELECT NOW(); SELECT * FROM City_backup;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    16
Current database: world
+---------------------+
| NOW()               |
+---------------------+
| 2015-01-31 07:12:06 |
+---------------------+
1 row in set (0.01 sec)
Empty set (0.00 sec)

 Conclusion: /> In this post, I shared some tools that can help you get rid of long-running transactions to help ensure that you don’t run into performance issues. This is one of the many good reasons to use Percona Server, which has some extra features on top of vanilla MySQL server.

 

id="__if72ru4sdfsdfrkjahiuyi_once" style="display: none;">
id="__hggasdgjhsagd_once" style="display: none;">
id="__if72ru4sdfsdfruh7fewui_once" style="display: none;">

The post rel="nofollow" href="http://www.percona.com/blog/2015/02/27/3-handy-tools-to-remove-problematic-mysql-processes/">3 handy tools to remove problematic MySQL processes appeared first on rel="nofollow" href="http://www.percona.com/blog">MySQL Performance Blog.

Written by in: innodb_kill_idle_transaction,Insight for DBAs,Muhammad Irfan,MySQL,percona server,Primary,pt-kill,Zend Developer |
Feb
26
2015
--

Who Wins The Battle of The Disrupted Tech Giants: HP Or IBM?

Two big football players wrestling for position. It’s been a rough several years for the once-mighty technology behemoths, HP and IBM, and while each has the cash and resources to chug along for years to come, both companies have struggled to find a foothold in a fast-changing market. HP once represented the archetypal Silicon Valley company, a pillar of the computer world, a place where a teenage Steve Jobs worked one summer and cut… Read More

Feb
26
2015
--

With $50M Boost, Silent Circle Aims Blackphone At Enterprise Security

Blackphone Encrypted comms company Silent Circle, one half of the SGP Technologies joint venture behind the pro-privacy Android smartphone Blackphone, has just announced it’s reached an agreement to buy out its hardware partner, Spanish smartphone maker Geeksphone. Read More

Feb
26
2015
--

Box’s Latest Vertical Package Focuses On Financial Services

Wall Street Bull Box has a plan to keep growing and it involves building vertical pillars on top of the base Box platform and APIs. To that end, Box announced a new financial services vertical today with a set of tools and technologies geared specifically to firms in the financial services industry. The company first revealed this vertical approach last Fall at the BoxWorks user conference, dubbing it Box… Read More

Feb
26
2015
--

Samsung Filed The Most Patents In Europe In 2014, U.S. Led The Field By Country

4661050938_1f40e33d08_b While IBM is number-one when it comes to the number of patents filed in the U.S., in Europe, Samsung is leading the pack. Today, the European Patent Office released 2014 figures for patents filed in the region, which showed that the Korean company, and currently the world’s largest smartphone maker, filed 2,541 for the full year. In terms of countries, the U.S. dominated the list,… Read More

Feb
26
2015
--

Worrying about the ‘InnoDB: detected cycle in LRU for buffer pool (…)’ message?

If you use Percona Server 5.5 and you have configured it to use multiple buffer pool instances than sooner or later you’ll see the following lines on the server’s error log and chances are you’ll be worried about them:

InnoDB: detected cycle in LRU for buffer pool 5, skipping to next buffer pool.
InnoDB: detected cycle in LRU for buffer pool 3, skipping to next buffer pool.
InnoDB: detected cycle in LRU for buffer pool 7, skipping to next buffer pool.

Worry not as this is mostly harmless. It’s becoming a February tradition for me (Fernando) to face a question about this subject (ok, it’s maybe a coincidence) and this time I’ve teamed up with my dear colleague and software engineer George Lorch to provide you the most complete blog post ever published on this topic(with a belated style="text-decoration: underline;">thank you! to Ernie Souhrada, with whom I’ve also discussed this same matter one year ago).

InnoDB internals: what is “LRU” ?

There’s a short and to-the-point section of the MySQL title="The InnoDB Buffer Pool" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/innodb-buffer-pool.html" rel="nofollow">manual that explains in a clear way what is the InnoDB buffer pool, how it operates and why it plays such an important role in MySQL performance. If you’re interested in understanding InnoDB internals then that page is a good start. In this section we’ll refrain ourselves to explain what the “LRU” that shows in our subject message is so we’ll only slightly dig into InnoDB internals, enough to make for some context. Here’s a quick introduction to the buffer pool, quoting from the above manual page:

InnoDB maintains a storage area called the buffer pool for caching data and indexes in memory. (…) Ideally, you set the size of the buffer pool to as large a value as practical, leaving enough memory for other processes on the server to run without excessive paging. The larger the buffer pool, the more InnoDB acts like an in-memory database, reading data from disk once and then accessing the data from memory during subsequent reads.

In practice, however, we can rarely fit our whole dataset inside the InnoDB buffer pool so there must be a process to manage this limited pool of memory pages:

InnoDB manages the pool as a list, using a variation of the least recently used (LRU) algorithm. When room is needed to add a new block to the pool, InnoDB evicts the least recently used block and adds the new block to the middle of the list.

There you go, InnoDB employs a variation of the Least Recently Used algorithm called midpoint insertion strategy to manage the pages within the buffer pool. We should mention it does title="MySQL Glossary - LRU" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_lru" rel="nofollow">makes exceptions, such as during a full table scan, when it knows the loaded pages might end up being read only a single time.

Dumping and reloading the buffer pool

Before we can get to the main point of this article lets first examine why would you want to dump the buffer pool to disk, which is at the core of the matter here: that’s when those warning messages we’re discussing may appear.

When you start a MySQL server the buffer pool is empty by default. Performance is at it’s worse at this point because no data can be found in memory so in practice each request for data results in an I/O operation to retrieve the data in the disk and bring it to memory. With time the buffer pool gets filled and performance improves – more and more data can now be found in memory. With yet more time we reach a peek performance state: the buffer pool not only is full but it is filled with the most popular data. The time between the start of the server and reaching this optimum state in the buffer pool is called server  title="MySQL Glossary - warm up" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_warm_up">warm up. How long it takes depends mostly on two things: the size of the buffer pool and the level of activity of the server – the less busy it is the less requests it will get and thus more time is needed until the popular data is fully loaded.

Now, there could be a shortcut: what if before we save the buffer pool on a disk file before we stop MySQL? We could later use it to reload the buffer pool to an optimum state when we restart the server, thus decreasing the warm up period dramatically.

Percona was a pioneer in this field related to other MySQL distributions and title="DUMP/RESTORE OF THE BUFFER POOL" href="http://www.percona.com/doc/percona-server/5.5/management/innodb_lru_dump_restore.html">implemented this functionality in Percona Server 5.5. Later on, MySQL 5.6 was released with a similar functionality which also allowed title="Preloading the InnoDB Buffer Pool for Faster Restart" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/innodb-preload-buffer-pool.html" rel="nofollow">preloading the buffer pool for a faster warm up. Percona Server 5.6 incorporates this upstream feature, effectively replacing its own implementation. However, while in Percona Server 5.5 we could periodically dump the buffer pool in MySQL and Percona Server 5.6 it is only dumped at title="innodb_buffer_pool_dump_at_shutdown" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_buffer_pool_dump_at_shutdown" rel="nofollow">shutdown or at title="innodb_buffer_pool_dump_now" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/innodb-parameters.html#sysvar_innodb_buffer_pool_dump_now" rel="nofollow">request.

“Detected cycle in LRU”

In the section above we introduced a functionality that allows to dump a fingerprint of the buffer pool to disk so we can later reload it at server restart (note that even though the buffer pool might be very large the fingerprint will be small enough to make this practical). What we didn’t mention was that this is yet most useful outside of maintenance time and planned shutdows – that is, when the server crashes. When a crash happens it’s that more important to bring it back to a warm up state soon, so it can resume providing data fast enough. And giving we cannot predict a crash the only way we can arrange to have the latest buffer pool on disk is by flushing it style="text-decoration: underline;">often.

While the buffer pool is divided into pages for efficiency of high-volume style="text-decoration: underline;">read operations it is title="MySQL Glossary - Buffer Pool" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/glossary.html#glos_buffer_pool">implemented as a linked list of pages, for efficiency of style="text-decoration: underline;">cache management. During the process of dumping the buffer pool to disk a mutex is acquired on the LRU list. However, this mutex is not hold for the duration of the process – it is periodically released to prevent stalling of the system. The problem is: in between the release of the mutex and the moment it is acquired again the list may get reshuffled. Since the dump keeps a pointer to its position across the mutex boundry, the dump can get put into some style="text-decoration: underline;">artificial cycling.

Lets consider a linked list:

A > B > C > D > E

where each letter corresponds to a memory page. Now lets say the initial dump was partially taken and covered the first three pages, “A > B > C”, placing a pointer on “C” before releasing the mutex. Once the mutex is reacquired the list has been reshuffled:  “A > C > B > D > E”. The resulting junction of the partial list we have already copied and the reshuffled list now includes a loop, which would incur in a cycle: “(A > B > style="text-decoration: underline;">C) > B > D > E”. When the dumping process detects a cycle on the LRU list it stops copying from the actual buffer pool, throws in a warning message, and moves on to the title="Using Multiple Buffer Pool Instances" rel="nofollow" href="http://dev.mysql.com/doc/refman/5.6/en/innodb-multiple-buffer-pools.html" rel="nofollow">next buffer pool instance – otherwise it would keep dumping in an infinite loop.

How harmless are those messages ?

It is fairly harmless except for the fact you will only have a partial LRU list dump for that buffer pool instance – that is, until the next dump occurs. If the server crashes or is shutdown before the next dump takes place the existing one won’t be totally up to date for the server warm up to complete – it will still be used and will still provide a partially filled, somewhat “warm” buffer pool, just not as optimal as it could have been if the last dump had been taken fully.

The post rel="nofollow" href="http://www.percona.com/blog/2015/02/26/worrying-about-the-innodb-detected-cycle-in-lru-for-buffer-pool-message/">Worrying about the ‘InnoDB: detected cycle in LRU for buffer pool (…)’ message? appeared first on rel="nofollow" href="http://www.percona.com/blog">MySQL Performance Blog.

Feb
25
2015
--

Google Makes A Push For The Mobile Enterprise Market With Launch Of Android For Work

android-work At a small press event in San Francisco today, Google officially launched Android for Work, a set of technologies that makes it easier for companies to adopt Android and allows their users to bring their own devices to work. The company first unveiled a preview of this technology during its I/O developer conference last summer, but as Google’s director for product management for… Read More

Feb
25
2015
--

Target Says Credit Card Data Breach Cost It $162M In 2013-14

Target When it comes to data breaches, retailers are one of the biggest targets these days, and today we have some detail on the costs around one of the more high-profile attacks. Target today said that it has booked $162 million in expenses across 2013 and 2014 related to its data breach, in which hackers broke into the company’s network to access credit card information and… Read More