Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completely crash if Maxmind returns 503 #28

Open
cblage opened this issue Sep 11, 2019 · 3 comments
Open

Completely crash if Maxmind returns 503 #28

cblage opened this issue Sep 11, 2019 · 3 comments

Comments

@cblage
Copy link

cblage commented Sep 11, 2019

Seems like Geolix will crash the app completely if the backend returns a 503

 ** (CaseClauseError) no case clause matching: {:ok, {{'HTTP/1.1', 503, 'Service Temporarily Unavailable'}, [{'cache-control', 'no-cache'}, {'connection', 'close'}, {'date', 'Wed, 11 Sep 2019 16:52:35 GMT'}, {'server', 'cloudflare'}, {'content-length', '8322'}, {'content-type', 'text/html; charset=UTF-8'}, {'x-frame-options', 'SAMEORIGIN'}, {'set-cookie', '__cfduid=de45f29ad402707842e8335e79bcfb4b51568220755; expires=Thu, 10-Sep-20 16:52:35 GMT; path=/; domain=.geolite.maxmind.com; HttpOnly'}, {'expect-ct', 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"'}, {'cf-ray', '514b272c4a61cefc-IAD'}], '<!DOCTYPE HTML>\n<html lang="en-US">\n<head>\n  <meta charset="UTF-8" />\n  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />\n  <meta name="robots" content="noindex, nofollow" />\n  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />\n  <title>Just a moment...</title>\n  <style type="text/css">\n    html, body {width: 100%; height: 100%; margin: 0; padding: 0;}\n    body {background-color: #ffffff; font-family: Helvetica, Arial, sans-serif; font-size: 100%;}\n    h1 {font-size: 1.5em; color: #404040; text-align: center;}\n    p {font-size: 1em; color: #404040; text-align: center; margin: 10px 0 0 0;}\n    #spinner {margin: 0 auto 30px auto; display: block;}\n    .attribution {margin-top: 20px;}\n    @-webkit-keyframes bubbles { 33%: { -webkit-transform: translateY(10px); transform: translateY(10px); } 66% { -webkit-transform: translateY(-10px); transform: translateY(-10px); } 100% { -webkit-transform: translateY(0); transform: translateY(0); } }\n    @keyframes bubbles { 33%: { -webkit-transform: translateY(10px); transform: translateY(10px); } 66% { -webkit-transform: translateY(-10px); transform: translateY(-10px); } 100% { -webkit-transform: translateY(0); transform: translateY(0); } }\n    .bubbles { background-color: #404040; width:15px; height: 15px; margin:2px; border-radius:100%; -webkit-animation:bubbles 0.6s 0.07s infinite ease-in-out; animation:bubbles 0.6s 0.07s infinite ease-in-out; -webkit-animation-fill-mode:both; animation-fill-mode:both; display:inline-block; }\n  </style>\n\n    <script type="text/javascript">\n  //<![CDATA[\n  (function(){\n    var a = function() {try{return !!window.addEventListener} catch(e) {return !1} },\n    b = function(b, c) {a() ? document.addEventListener("DOMContentLoaded", b, c) : document.attachEvent("onreadystatechange", b)};\n    b(function(){\n      var a = document.getElementById(\'cf-content\');a.style.display = \'block\';\n      setTimeout(function(){\n        var s,t,o,p,b,r,e,a,k,i,n,g,f, yIvmnzq={"APHx":+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![])+(+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![]))/+((!+[]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![])+(!+[]+!![]+!![]+!![])+(+[])+(!+[]+!![]))};\n        g = String.fromCharCode;\n        o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";\n        e = function(s) {\n          s += "==".slice(2 - (s.length & 3));\n          var bm, r = "", r1, r2, i = 0;\n          for (; i < s.length;) {\n              bm = o.indexOf(s.charAt(i++)) << 18 | o.indexOf(s.charAt(i++)) << 12\n                      | (r1 = o.indexOf(s.charAt(i++))) << 6 | (r2 = o.indexOf(s.charAt(i++)));\n              r += r1 === 64 ? g(bm >> 16 & 255)\n                      : r2 === 64 ? g(bm >> 16 & 255, bm >> 8 & 255)\n                      : g(bm >> 16 & 255, bm >> 8 & 255, bm & 255);\n          }\n          return r;\n        };\n        t = document.createElement(\'div\');\n        t.innerHTML="<a href=\'/\'>x</a>";\n        t = t.firstChild.href;r = t.match(/https?:\\/\\//)[0];\n        t = t.substr(r.length); t = t.substr(0,t.length-1); \n        a = document.getElementById(\'jschl-answer\');\n        f = document.getElementById(\'challenge-form\');\n        ;yIvmnzq.APHx-=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![])+(+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(+!![]))/+((!+[]+!![]+!![]+!![]+[])+(+!![])+(!+[]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![])+(!+[]+!![]+!![]+!![])+(+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]));yIvmnzq.APHx+=+((!+[]+!![]+!![]+!![]+!![]+!![]+!![]+[])+(!+[]+!![]+!![]+!![]+!![]+!![]+!![]+!![]+!![])+(!' ++ ...}}
agentrisk_1    |     (geolix) lib/geolix/adapter/mmdb2/reader.ex:13: Geolix.Adapter.MMDB2.Reader.read_database/1
agentrisk_1    |     (geolix) lib/geolix/adapter/mmdb2/loader.ex:33: Geolix.Adapter.MMDB2.Loader.load_database/1
agentrisk_1    |     (geolix) lib/geolix/database/loader.ex:66: anonymous fn/1 in Geolix.Database.Loader.handle_cast/2
agentrisk_1    |     (elixir) lib/enum.ex:769: Enum."-each/2-lists^foreach/1-0-"/2
agentrisk_1    |     (elixir) lib/enum.ex:769: Enum.each/2
agentrisk_1    |     (geolix) lib/geolix/database/loader.ex:64: Geolix.Database.Loader.handle_cast/2
agentrisk_1    |     (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
agentrisk_1    |     (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
@cblage
Copy link
Author

cblage commented Sep 11, 2019

After upgrading to 1.0, the problem still persists, but with a different error

agentrisk_1    |      ** (exit) exited in: :gen_server.call(Geolix.Server.Pool, {:checkout, #Reference<0.1273179890.3252420613.173863>, true}, 5000)
agentrisk_1    |          ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
agentrisk_1    |      stacktrace:
agentrisk_1    |        (stdlib) gen_server.erl:223: :gen_server.call/3
agentrisk_1    |        (poolboy) /opt/app/deps/poolboy/src/poolboy.erl:63: :poolboy.checkout/3
agentrisk_1    |        (poolboy) /opt/app/deps/poolboy/src/poolboy.erl:82: :poolboy.transaction/3
agentrisk_1    |        (agentrisk) lib/agentrisk/integrations/geolix.ex:7: Agentrisk.Integrations.Geolix.lookup/1
...

@mneudert
Copy link
Member

I will update the adapter to properly log an error for any non 200 status code so the app can start without problems. You will still need to take care of manually triggering a reload in this (hopefully rare) case as there is no retry of any sort.

The different error after the update however is "interesting" 🤔

@cblage
Copy link
Author

cblage commented Sep 12, 2019

I fixed it by shipping static DBs on every build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants