title: Mysql Sleeping connections keeping rows locked
body: <p>I have an application developed in C# which uses MySql as Database. sometimes, when inserting or updating records application faces locked timeout expired error.</p>
  
  <p>I noticed that there were some sleep commands (show full processlist;) which were locking some rows.</p>
  
  <p>Why sleeping commands are locking the rows???</p>
  
  <p>On my server, sleeping commands got killed after 8 hours as shown in </p>
  
  <pre><code>show variables like 'wait_timeout';
  </code></pre>
  
  <p>and</p>
  
  <pre><code>show variables like 'interactive_timeout';
  </code></pre>
  
  <p><strong>Is it OK to set this timeout for 30 seconds by following queries?</strong></p>
  
  <pre><code>SET @@GLOBAL.wait_timeout=30;
  SET @@GLOBAL.interactive_timeout=30;
  
  SET session wait_timeout=30;
  SET session interactive_timeout=30;
  </code></pre>