{"id":12660,"date":"2010-07-03T11:47:38","date_gmt":"2010-07-03T09:47:38","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=12660"},"modified":"2010-07-03T11:47:38","modified_gmt":"2010-07-03T09:47:38","slug":"the-saga-of-a-lost-connection","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2010\/07\/03\/the-saga-of-a-lost-connection\/","title":{"rendered":"The saga of a lost connection"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across an interesting problem at work a couple of days ago. \u00a0One of our CakePHP-based applications has a scheduled task (cronjob) that runs every minute and imports mail from a number of IMAP mailboxes into the database. \u00a0All of a sudden the script broke. \u00a0In a very particular way. \u00a0Not a single line of code was change in the script itself, and there were no significant changes in the rest of the application that the script is using. \u00a0But one day, for some reason, it started to import emails from only half of the mailboxes, completely ignoring the rest.<\/p>\n<p>A lengthy midnight drunk debugging session helped to realize the problem. \u00a0Apparently, in the list of mailboxes to check there were a few old mailboxes, which were not used anymore for any email. \u00a0The script was checking them but they were always empty. \u00a0Server administrator removed those mailboxes during a scheduled maintenance window. \u00a0Now, the script couldn&#8217;t connect to the mailbox anymore. \u00a0No problem, there was error handling for this case. \u00a0But was error handling didn&#8217;t take into account is the combination of time it takes timeout on the non-existing mailbox check and the database connection timeout.<\/p>\n<p>It so happened, that these few old mailboxes were right in the middle of the list of all mailboxes. \u00a0The script was importing mail from the first few mailboxes just fine. \u00a0But then while it was taking a long time to timeout on a few non-existing mailboxes, the database connection got closed due to the inactivity timeout. \u00a0This wasn&#8217;t handled properly. \u00a0The script was only checking for the existing database connection at the beginning, when it was opening the connection &#8211; not later on. \u00a0As the result, nothing could have been imported from the rest of the mailboxes.<\/p>\n<p>As always, once you know the problem, you also know how to fix it or work around it. \u00a0But troubleshooting a problem like this is tricky. \u00a0Seeing the queries working for one mailbox and not working for another is disorienting at least. \u00a0Having no recent changes to the application doesn&#8217;t help either. \u00a0And the problem being not in the code itself, but in the resources is also not very obvious.<\/p>\n<p>So, here you go. \u00a0If you ever have a weird problem like that &#8211; check that your resources (database connection, network connection, file handler) are still available to you.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across an interesting problem at work a couple of days ago. \u00a0One of our CakePHP-based applications has a scheduled task (cronjob) that runs every minute and imports mail from a number of IMAP mailboxes into the database. \u00a0All of a sudden the script broke. \u00a0In a very particular way. \u00a0Not a single line &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2010\/07\/03\/the-saga-of-a-lost-connection\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">The saga of a lost connection<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[1559,38,74],"keyring_services":[],"class_list":["post-12660","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-databases","tag-php","tag-tips"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":60,"url":"https:\/\/mamchenkov.net\/wordpress\/2002\/06\/07\/random-bits-5\/","url_meta":{"origin":12660,"position":0},"title":"Random bits","author":"Leonid Mamchenkov","date":"June 7, 2002","format":false,"excerpt":"Lots of small things today: monthly backups scheduled, inserted few fresh tapes into the cycle, played with Mutt 1.4 (found it much faster with opening\/closing\/sorting of mailboxes then 1.2), upgraded GeForce2 to the one with 64 MBytes of memory, revisited Subversion website (modern alternative to CVS), some other small fixes\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26001,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/06\/sugarcrm-roundcube-and-request-tracker-integration-on-a-single-domain\/","url_meta":{"origin":12660,"position":1},"title":"SugarCRM, RoundCube and Request Tracker integration on a single domain","author":"Leonid Mamchenkov","date":"April 6, 2016","format":false,"excerpt":"In my years of working as a system administrator I've done some pretty complex setups and integration solutions, but I don't think I've done anything as twisted as this one recently. \u00a0The setup is part of the large and complex client project, built on their infrastructure, with quite a few\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"SAML workflow","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2016\/04\/saml_workflow_vertical-500x469.gif?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18187,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/05\/20\/actions-in-gmail\/","url_meta":{"origin":12660,"position":2},"title":"Actions in Gmail","author":"Leonid Mamchenkov","date":"May 20, 2013","format":false,"excerpt":"I think this is the greatest innovation in web-based email since Gmail's own release of large mailboxes (what was it? 1 GB?). \u00a0 Web mail has all the benefits of a website, but offers greater contextual focus. \u00a0 Adding specific actions to message has been a possible with extensions and\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2013\/05\/gmail-actions.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":10030,"url":"https:\/\/mamchenkov.net\/wordpress\/2006\/04\/03\/hiding-behind-spf\/","url_meta":{"origin":12660,"position":3},"title":"Hiding behind SPF","author":"Leonid Mamchenkov","date":"April 3, 2006","format":false,"excerpt":"After playing for some time with DNS Stuff, I decided to configure SPF for mamchenkov.net domain.\u00c2\u00a0 I don't have a lot of expectations, but I hope that it'll help to fight all that SPAM that we have on the web.\u00c2\u00a0 As a side effect, hopefully emails to Hotmail and Yahoo!\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":23,"url":"https:\/\/mamchenkov.net\/wordpress\/2002\/03\/04\/new-mutt-packages-quake-iii-and-book-order\/","url_meta":{"origin":12660,"position":4},"title":"New mutt packages, Quake III, and book order","author":"Leonid Mamchenkov","date":"March 4, 2002","format":false,"excerpt":"I have put online new mutt rpms and configs with S\/MIME support and LDAP address book configuration. No NNTP and compressed mailboxes support this time. Outlook appointments converter to ical calendar is available though. After long tweaking and changing all possible and impossible settings I actually managed to fix my\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16613,"url":"https:\/\/mamchenkov.net\/wordpress\/2012\/08\/11\/gmail-saga-forwarding-filters-and-pop-3\/","url_meta":{"origin":12660,"position":5},"title":"Gmail saga : forwarding, filters, and POP-3","author":"Leonid Mamchenkov","date":"August 11, 2012","format":false,"excerpt":"A few days ago I've mentioned that I have a problem with some of my email accounts. \u00a0The thing was that I have a few mailboxes, and all of them forward all incoming messages to a single account that I use for everything. \u00a0Some of the accounts forward emails using\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/12660","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=12660"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/12660\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=12660"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=12660"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=12660"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=12660"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}