Comments (11)
The PoolError
says that you're out of connections, which means you've gone over the limit of 1000. db.batch
requires a connection for each query (more or less).
I don't really know where the InterfaceError: cursor already closed
comes from. Cursors shouldn't be closed. And there is not really a way to reuse cursors, because it would involve manually setting the connection state and callbacks. So that's why the cursor is hidden away in the connection class ans is inly used for fetching data after a query has been done.
from momoko.
Right, but once the big batch is done my connection pool should drop, right? Postgres shows that these connections are gone so when I start a new batch I should be starting from scratch, right? Like i said, this is probably me doing something wrong.
On Sep 29, 2012, at 2:43 AM, Frank Smit [email protected] wrot
The PoolError says that you're out of connections, which means you've gone over the limit of 1000. db.batch requires a connection for each query (more or less).
I don't really know where the InterfaceError: cursor already closed comes from. Cursors shouldn't be closed. And there is not really a way to reuse cursors, because it would involve manually setting the connection state and callbacks. So that's why the cursor is hidden away in the connection class ans is inly used for fetching data after a query has been done.
—
Reply to this email directly or view it on GitHub.
from momoko.
It should. Your code looks correct to me, so the only thing I can think of is that too much connections are needed or something goes wrong inside of Momoko. Can you give me more information about he amount of queries and data? I can make a test case and see if I can reproduce it.
from momoko.
I came across an issue with cursors on the rewrite branch. In the busy() getter on Connection, the parentheses are missing on the call to isexecuting. That keeps the connections from being cleaned up.
from momoko.
I saw your pull request and merged it.
from momoko.
Thanks!
On Wed, Oct 10, 2012 at 3:57 AM, Frank Smit [email protected]:
I saw your pull request and merged it.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/34#issuecomment-9294375.
from momoko.
I'm getting the same issue on 1.0.0b2 when the database is hit hard, particularly with a yield to an array of moko.Op's. The queries are heavy, it's a local (internal) application and can take between half a second and five seconds to execute.
The relevant parts of the stack trace are
File "D:...\momoko-1.0.0b2-py3.2.egg\momoko\connection.py", line 287, in io_callback
self.callback(None)
results[i].fetchall()
psycopg2.InterfaceError: cursor already closed
from momoko.
Ok, I think I might have an idea of what is going wrong. The connection might be closed before the results are fetched from the cursor. I'm not completely sure, but after running a small test I get the same error.
I'm at work/internship at the moment so I can't dive into right now. I have time later tonight.
from momoko.
Thanks, much appreciated.
from momoko.
I'm stuck. What I think is happing is that the connection is closed by the connection pool cleaner while the cursor is still being used.It seemed easy to fix by keeping a set of weak references to the cursors in the Connection
class. When the set is empty (it becomes empty when the cursors are deleted by the garbage collector) the connection can be closed again. But I can't get it to work. I'm trying to figure out why. I also wasn't able to find anything in Psycopg2's connection class that idicates that there are still opened cursors. That would have made it a lot easier. Maybe I'm also overthinking it.
You could try disabling the pool cleaner by setting cleanup_timeout
to 0
and setting the minimum amount of connections to a appropriate amount for now.
I'm going to FOSDEM tomorrow so I don't much time, but I'll try to come up with something while I'm on the train!
from momoko.
@arielakeman, @swasheck. I've written about a possible solution in #41.
from momoko.
Related Issues (20)
- momoko makes IOError in ioloop HOT 3
- Behavior of .execute() wo parameters does not match psycopg2 HOT 1
- code in ConnectionContainer.all_dead conflicts with Pool.putconn HOT 4
- The future returned by Connection.execute will never resolve HOT 1
- self.conns.empty() in Pool.close will not work as expected by big chance HOT 3
- How can I run the first sample of momoko HOT 6
- Pool fails to reconnect when using Unix-domain socket (OperationalError: server closed the connection unexpectedly) HOT 18
- Restarting PostgreSQL sometimes causes Pool.getconn() to hang HOT 5
- Momoko Pool trying to use dead connections HOT 3
- Writing tests for tornado app, which uses momoko for postgres DB. HOT 2
- Cannot add momoko HOT 1
- Please help me figure out why this code freezes forever HOT 8
- Any suggestion on how I'd commit/rollback using a connection pool? HOT 3
- when using RealDictCursor, Pool.register_json error HOT 2
- Typo in connection.py (socker instead of socket) HOT 2
- error if trying to connect pool while Postgress is not online HOT 2
- NamedTupleCursor factory test is executed even if MOMOKO_TEST_HSTORE is disabled HOT 1
- Debian packaging HOT 1
- AttributeError: 'Future' object has no attribute 'set_exc_info' HOT 5
- Not worked with python 3.7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from momoko.