<div style="display: flex; flex-wrap: wrap; white-space: pre-wrap; align-items: center; "><img height="20" width="20" style="border-radius:50%; margin-right: 4px;" decoding="async" src="https://avatars.githubusercontent.com/u/7535628?s=20&v=4" /><strong>rkoeze</strong> created an issue <a href="https://github.com/openstreetmap/openstreetmap-website/issues/6572">(openstreetmap/openstreetmap-website#6572)</a></div>
<h3 dir="auto">Problem</h3>
<p dir="auto">We currently use Ruby’s Timeout to guard against long-running operations, including DB queries. This has a few issues:</p>
<ul dir="auto">
<li>Timeout can inject an exception into a thread at essentially any point. That kind of behavior is hard to reason about. <a href="https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/" rel="nofollow">It can also leave resources in an inconsistent state</a>.</li>
<li>Rails may wrap these exceptions, so we have to add monkeypatches <a href="https://github.com/openstreetmap/openstreetmap-website/blob/0d93c131fa13ef238cee2ba3e63abd404cb05fce/config/initializers/abstract_adapter.rb">like this</a>.</li>
<li>We still see long running queries despite those queries being wrapped with Timeout.</li>
</ul>
<h3 dir="auto">Description</h3>
<p dir="auto">We should not rely on the Timeout library for long running operations. As an alternative, we might consider doing the following:</p>
<ul dir="auto">
<li>Use DB-level timeouts (e.g. <code class="notranslate">statement_timeout</code>) with a reasonable default. We recently added <a href="https://github.com/openstreetmap/chef/commit/2943e2cb7e273b139f796fee86323b4882461340">a 5 minute timeout</a> as a backstop. I would recommend bumping that down.</li>
<li>Ensure all network requests are also guarded by a timeout.</li>
<li>For other long running code inside our application, consider explicit deadline checks.</li>
</ul>
<p dir="auto">Not having access to data on request and DB query times, it's a little hard to say what these timeout values should be.</p>
<h3 dir="auto">Screenshots</h3>
<p dir="auto"><em>No response</em></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/6572">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLKSIX6GFV7EWSBXM7T37NNRJAVCNFSM6AAAAACNTS3K36VHI2DSMVQWIX3LMV43ASLTON2WKOZTGY3TQNBSGU4TGMQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLM35C35PUR25PMIRWT37NNRJA5CNFSM6AAAAACNTS3K36WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHNWQCTJQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/6572</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>

<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/6572",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/6572",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>