Matthew
Any idea what’s wrong?
Matthew
active is set to true on all rows in that table
Alexander
Can you show a traceback?
Matthew
J J
Should it not be FacebookPage.select()
J J
without the ()
Matthew
LOL yes
Matthew
I feel silly 😄
J J
Happens 😅
Matthew
existing_facebook_post = FacebookPost.get(lambda p: p.facebook_id == post_id and p.facebook_page == self.facebook_page)
Matthew
This query works most of the time
Matthew
Sometimes, it gives AssertionError:
Matthew
I have updated Pony to 0.7.13
Matthew
Any ideas?
Matthew
stacktrace: https://gist.github.com/matthewrobertbell/595368323a17496d010c7c0894c7c4af
Matthew
The query works fine with that exact data when I run it on its own
Matthew
The same error if I do a select query rather than get
Alexander
Hi Matthew! This is indeed a bug. I pushed the fix on GitHub, you can check if it works for you
https://github.com/ponyorm/pony/commit/09ed56fa2ed36e5deae1cf1aeb17bdecc5191816
Alexander
Alexander
https://github.com/ponyorm/pony/commit/bcfec2cc50d5725a54643610453577e14e4c3d8e
Alexander
https://github.com/ponyorm/pony/commit/2f635b667031ab374adbedc4834dccdc95dc65d7
Alexander
https://github.com/ponyorm/pony/commit/ed379264afb23e6882ea6b030ea5ef389e6e5a36
Alexander
Muhammed
Matthew
Matthew
@metaprogrammer with pony installed from github master I get the same AssertionError, it looks like the exact same stack trace
Matthew
I also tried pip install git+https://github.com/ponyorm/pony.git@orm to install from orm branch but the same error occurs
Alexander
Hmm, maybe I was too fast. I fixed very similar problem just before your report, and thought it is the same. Let me check...
Alexander
Hi @matthewrobertbell, can you check again? It should work now
Matthew
With git orm branch? I will when I get back to my computer
Alexander
yes, orm branch
Alexander
thanks
Matthew
This worked, thank you very much! Do you plan a new release soon which would include recent bug fixes?
Alexander
Yes, I hope we will make release on this week
Matthew
Thank you, please let the channel know when you do 🙂
Alexander
Sure!
Matthew
What was the problem which caused the bug?
Matthew
cool, good to know
Vitaliy
This is greatest thing! In my application I’ve implemented my own powerful “events” layer based on before/after hooks. Sometimes on some complex scenarios I ran into assertion errors related to prefetch context. To resolve these error I made some refactoring and workarounds. Thank you!!!
Henri
Anonymous
Hi,
i'm checking reconnections forcing a database shutdown. but On a pny.exists() query, and i'm getting a :
"
psycopg2.OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 19999?
"
This qquery is the first step in a long runing process(reading kafka topic) raising this exception, break de flow and read a new msg so... i lost the control... i'm expecting to keep the flow in a neverending loop tring to reconect... is any way to achieve that?
Alexander
Hi, if this is the first step, and you expect that connection will work after some time, you can write:
while True:
try:
pny.exists(some_test_sql)
except OperationalError:
rollback()
else:
break
Anonymous
but... is something that could be articulate on a general way
Anonymous
as... i have a lot of db access in per msg/flow
Anonymous
and i guess that i'm getting this exception because is the first query on the flow
Anonymous
on my case i need to freeze the flow when i detect a db disruption
Alexander
If I understand the use-case correctly, you can wrap this code into some function and use it as a first step of the flow
def wait_for_connection():
while True:
try:
pny.exists(some_test_sql)
except OperationalError:
rollback()
else:
break
def process_message():
wait_for_connection()
... # start doing other stuff
msg = read_message()
process_message(msg)
Alexander
If the goal is to wait some time until the server is up again
Anonymous
The use case could be summarize as a long running job doing:
Read Msg from Queue -> Per msg make different operations(including 6/7 db calls) -> ack msg
Anonymous
my best guest could be freeze the operation flow when i detect a db problem to resume later(when db up)
Matthew
Matthew
I am getting this fairly frequently in my background workers, is this a bug or a problem with my code?
Matthew
I am using db_session(strict=True)
Matthew
This is also happening without strict=True. Could it be another bug?
Michele
Can I update a table's structure without deleting the table from the database and create it again? I tried adding the field on the class but it doesn't work :(
Alexander
At this moment you need to manually perform ALTERE TABLE command
Alexander
Michele
Matthew
What other details would be helpful?
Alexander
Can you comment out this assertion and look what happens after that?
Matthew
if you mean things like before_insert, I don’t think so, but it is hard to tell from sentry
Matthew
the issue is this happens very rarely
Matthew
so it is hard to investigate
Alexander
maybe you can add try/except to before_insert with some error reporting
Matthew
If before_insert failed, wouldn’t it show up in the exception?
Alexander
Currently it should
Alexander
If you dont' catch it somewhere
Alexander
In general, what should Pony do if during flush() it need to save 10 objects, and in before_insert the second object throws an exception? Should it suppress the exception and continue saving the rest 8 objects? Or should it immediately abort the current transaction?
Matthew
abort I think
Alexander
So, when before_insert hook of any object throws an exception, Pony should switch db_session's state to "invalid". Even if the user code catch the exception and try to continue current db_session, Pony will refuse to do this
Matthew
Is that what happens now or what you want to happen?
Alexander
What I want to happen. Right now I think it stop saving unsaved objects and raises an exception. And if a user code catch this exception and continue working in current db_session it should get the assert that you have get
Matthew
Ok, so I’ll try and look to see if there is an exception being caught in my code somewhere
Muhammed
Hi, how can I combine more than sets? For example
category1.products + category2.products
and
.products = Set(Product)
Can I use + sign?
Matthew
try set(cat1.products) | set(cat2.products)
Matthew
if you want products in either
Matthew
(that’s not in a query)
Muhammed
I use sort_by, filter_by etc. after merging