-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Prevent postgrest from starting if DB is not available #682
Comments
I had this same issue, strangely enough. The details of my specific case are possibly a bit odd, but posting this for posterity. I was running both PostgreSQL and PostgREST as docker containers on the same host. The networking mode was set to use (I think), Rancher's overlay networking even though this had not been enabled in this Rancher instance (running an old version of rancher-agent, 0.8.2). Bizarrely, POST with multiple elements in an array did succeed and did create new records in the database. But POST with single element resulted in exactly the above error ("Something went wrong"). Also, POSTing an empty body to a non-existent URL failed with the same error, e.g.
Though a GET fails with the expected 404:
The fix in my case was to switch to using the (default in docker) "bridge" networking. I also ran both PostgreSQL and PostgREST in the same network namespace, allowing them to communicate over "localhost". So I'm not completely sure which of the two changes solved it, and I have no hypothesis for what exactly would cause the observed behavior. Would it be possible to provide a better error message in this (truly bizarre) case? Thanks |
Thanks for providing more info to reproduce the error. It's hard to know the exact place in the code which causes this error. I can make a branch for you to run which uses exceptionResponseForDebug. It would include exception details in the server response. This also might be a good time to revisit #540 to enable customizing the verbosity of server logs with a flag. |
@begriffs Sure, if you make a branch, I will try to reproduce and hopefully get some more clues. |
I run into the same problem on second server. The really weird thing is that it used to work ok some 3 weeks ago, but it is not anymore and it allows POSTing only multiple items (I have scripts I run at that time, they do not work anymore). |
@begriffs
with a single header A) not working (returning 500 Internal Server Error - Something went wrong) {
"number": 1,
"text": "test 1"
} B) working ok (201) [
{
"number": 1,
"text": "test 1"
}, {
"number": 2,
"text": "test 2"
}
] (The table CREATE TABLE public.test
(
"number" bigint NOT NULL,
"text" text
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.test
OWNER TO postgres;
GRANT ALL ON TABLE public.test TO postgres;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.test TO author;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.test TO anon;
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.test TO admin; ) (Any idea what can be wrong /how to solve this/ would be greatly appreciated as my app https://hlasovali.cz stopped working for inserting new data because of this issue.) |
@michalskop sending a single item is not supported (nowhere in the docs does it say this is the way to do it) however this was implemented in a recent PR that is merged #634 you'll need to compile it yourself or wait for a release |
@ruslantalpa thanks! However it does say so in the documentation here http://postgrest.com/api/writing/, the very first example: { "col1": "value1", "col2": "value2" } But it could be overcome by always posting as an array, but neither this works: C) not working (500 - something went wrong) [
{
"number": 1,
"text": "test 1"
}
] Therefore there is no way how to insert a single item. |
jumped to conclusion ... sorry. will look into it a bit later |
I see your url is https, which means it goes through a proxy. Can you try postig directly to postgrest? Go to our gitter channel and i'll help you debug |
Note: so it seems working ok if started Postgrest manually or restarting manually the service (sudo service postgrest restart), but it does not work if postgrest is started automatically on reboot (using /etc/init/postgrest.conf) |
On the master branch it now checks for a db connection and dies on startup if it cannot connect. |
I may be missing something, but I can (with Content-Type: application/json) :
with multiple data
(returning correctly 201)
But I cannot do the same POST with just a single item
nor with
Both returning 500 Internal Server Error with Something went wrong and with headers:
Connection →close
Content-Type →text/plain; charset=utf-8
Date →Mon, 25 Jul 2016 21:11:01 GMT
Server →postgrest/0.3.2.0
Transfer-Encoding →chunked
(running Postgres 9.5 on Ubuntu 14.04, tried in Postman and using PHP)
There is no information neither in Postgres log nor in syslog.
Any idea what may be wrong?
The text was updated successfully, but these errors were encountered: