-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: 🚑 Fix connection to the db failing when db_reset=True #34
Conversation
This does seem to fix it. I've tested a few valis routes, the cone search and db info search, and they worked. I also tested the zora search submission, which works. However the target page from zora doesn't work, and throws the same error. This may be related to the concurrent queries from the Target page. I'd like to preserve that if possible since it speeds up page loading. As for the |
""" Sub-dependency for get_db that resets the context connection state """ | ||
|
||
from valis.main import settings | ||
|
||
if settings.db_reset: | ||
pdb._state._state.set(db_state_default.copy()) | ||
pdb._state.reset() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in development mode, wrapping this back into a Dependency makes the first query slow since that's when it's first establishing the connection, but then all subsequent queries are fast. I think this is ok.
Another question is should we just make the default be |
Ok, I'll have a look at that issue. I think right now if I think by default valis/python/valis/settings.py Line 42 in 3468f2e
catalogdb tables, which causes a non-negligible overhead. That could make quick queries to take several times what they should due to the reflection, which anyway is not needed. But I think there are ways to prevent that (or we can add options to sdssdb ).
|
OK, can you give this one more try after pulling? Note that I have also update sdssdb to 0.12.3. This is not strictly necessary for this issue but 0.12.2 would cause reflection of I cannot say I fully understand the issue yet, but there seemed to be two additional problems:
With these changes the Zora target page works for me in all cases ( But this is looking like a serious hack at some point. In a different issue we should consider alternatives, but I'll write a couple ideas here for now:
|
The tests are failing right now but I think that will be fixed by merging #36 first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me testing with prod gunicorn and dev uvicorn. I think this is good for now for the betas. I agree that this could be hacky, and we can see how it performs during the beta and performance testing.
I like the idea of exploring switching to sqlalchemy2. In sdssdb
, there's some general migration work needed to bump sqlalchemy >2
, plus testing with the new query syntax. And new work to implement the Async
options. I started a branch of that a while back but it needs revisiting.
I played around with SQLModel
a bit early on, but haven't come back to it lately. My main issue with it was there didn't seem to be a way to wrap existing SQLA Models and convert them to SQLModels
. I didn't want to redefine what we have in sdssdb
. I like its idea of combining the FastAPI response model with the db model, since currently I have to define new very similar classes.
Sounds good, let's merge this for now and look at long-term solutions. |
Attempt at fixing #32. The problem seems to be related to the
ContextVar
for_state
and the fact that the previous change removed the fastapi dependency.