On Sat, 28 Dec 2013 15:13:39 -0800 (PST) irq <[email protected]> wrote: > This is my excersise on making many ->pg() calls in one request. It > seems that on first and second step two different database > connections are made, and for each remaining step these two > connections are picked alternatively. This is not what I want if I, > for instance, need AutoCommit = 0 or need to use temp tables. So I > need to make sure the same database connection is used all the time. > > What am I doing wrong?
You're expecting plugin to behave as you want and not as it is documented. Documentation doesn't say that it will be the same connection every time. If you look into source you will see that it creates a pool of connections. ->pg allows you to execute a single statement, if you want to commit you can do it in callback (see example in documentation), if you need to execute several related statements, this plugin won't help you. Problem is that to execute several statements you have to lock connection to exclusively serve a particular request. Event-driven application may process multiple requests simultaneously. So what if ->pg will use a single db connection and you will use it to submit a sequence of queries and then your application will try to process several requests at a time all sending their queries through a single DB connection? I think you should create a pool of connections and each request should be able to get connection from the pool and use it exclusively and return it to the pool when it don't need it anymore. This particular plugin doesn't provide such functionality. Pavel Shaydo -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/groups/opt_out.
