<p></p>
<blockquote>
<p>Is the story that each action has to use a single database and the timeout is actually about sending read actions to a write database if there has been a recent write action?</p>
</blockquote>
<p>If there's been a recent write action in the same session, yes. So if you e.g. save your profile then for the next two seconds, all your read requests are routed to the write database. After that, your a session goes back to the normal get/head => read database, everything else => write database.</p>
<p>We can override the default connection within a controller action (e.g. updating the status of a message when it's viewed) but by default the connections are automatically chosen based on the http verb.</p>
<p>See <a href="https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector.rb#L58-L71">https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector.rb#L58-L71</a> and <a href="https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector/resolver.rb#L34-L40">https://github.com/rails/rails/blob/7ddf2b7c0c8ff97b0a50e963b24bf2b82950988d/activerecord/lib/active_record/middleware/database_selector/resolver.rb#L34-L40</a></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/2634#issuecomment-634737725">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLP4OPY6HJXP2N4JXV3RTUWDPANCNFSM4NMGKH5Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAK2OLK3DEK2OFFMJPJAQULRTUWDPA5CNFSM4NMGKH52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEXKVIPI.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/2634#issuecomment-634737725",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/2634#issuecomment-634737725",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>