Giter VIP home page Giter VIP logo

Comments (7)

wulczer avatar wulczer commented on August 26, 2024

I tried with d13f8ff and got this: https://gist.github.com/1354828

IOW, when trying a nonexistent table, an error is reported and when using a wrong password a traceback appears.

The reason you get a traceback is that you should explicitly close() the connection that you opened. Adding

d.addErrback(lambda _: conn.close())

just before

d.addBoth(lambda _: reactor.stop())

makes the traceback go away for me.

The weird thing is that you seem to be getting a traceback with both configurations.

from txpostgres.

wulczer avatar wulczer commented on August 26, 2024

Ah, just saw something and gave it a try... and bingo. Using the select reactor gives me a traceback both of the times. Thank you @oberstet for the test case, I'll have to investigate by select behaves different than poll (which is the default on Linux)

from txpostgres.

oberstet avatar oberstet commented on August 26, 2024

ah, ok.

here are my results (FreeBSD):

b) bad password

the problem goes away when adding the

d.addErrback(lambda _: conn.close())

for both using select reactor or new kqueue reactor.

Ok, however I'm wondering: this seems to be different from what I do with standard adapi

https://github.com/oberstet/txpostgres/blob/testing/testing/adbapi_error.py

which is happy without the close. Is this related to the asynch. connection establishment?

a) nonexistent table

select() reactor: problem THERE
poll() reactor: problem NOT there
new kqueue() reactor: problem NOT there

with FreeBSD, the select reactor is default .. currently.

from txpostgres.

wulczer avatar wulczer commented on August 26, 2024

OK, this one is as tricky as they come.

The chain of events is:

  • Postgres finishes the authentication process, sends the OK over the wire
  • the specialised doRead gets called on the connection object
  • base PollingMixin's doRead gets called, gets POLL_OK
  • the Deferred returned from connect() callbacks
  • the connection starts watching the socket for notifies
  • a cursor is created and runs a query
  • the cursor tells the connection to stop watching the connection sends the query to the server, adds itself as a reader for the socket
  • the call to base doRead returns (sic!) and the connection checks for notifies and starts watching the socket
  • doRead is called on the connection which calls poll(), which raises a "nonexistent table" exception
  • the connection has no current Deferred, so it reraises the exception and boom, Unhandled error

So in fact this is a reentrancy issue with cursorRunning/cursorFinished, kind of. Let me think about how to handle this...

from txpostgres.

wulczer avatar wulczer commented on August 26, 2024

I think the issue is solved (at least in my testing I consistently got correct results - no tracebacks).

Thanks for the report!

from txpostgres.

oberstet avatar oberstet commented on August 26, 2024

Perfect!

Just tested select(), poll() and new kqueue() reactor on FreeBSD .. all 3 work with both test examples! Identical behavior.

Thanks alot for nailing down this tricky stuff;)

Tobias

from txpostgres.

smira avatar smira commented on August 26, 2024

Thanks, the patch is identical to what I've had in my queue for 'recursion depth exceeded' exception under heavy load!

from txpostgres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.