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
Regression in lazy loading strategy for sharded setups #4228
Comments
Changes by Rishi Sharma (@rishirishi):
|
3 similar comments
Changes by Rishi Sharma (@rishirishi):
|
Changes by Rishi Sharma (@rishirishi):
|
Changes by Rishi Sharma (@rishirishi):
|
Michael Bayer (@zzzeek) wrote: ok will confirm your patch is the right approach thanks! |
Changes by Michael Bayer (@zzzeek):
|
Rishi Sharma (@rishirishi) wrote: Hi Michael, I imagine you are really busy. Is there something with the patch that needs changing? I can try to help. We are eager to upgrade to 1.2. Thanks! -Rishi |
Michael Bayer (@zzzeek) wrote: I've been mentally linking this to another sharding related issue but this is more of a bug than the other one which is more of a feature request, so let me take a look |
Michael Bayer (@zzzeek) wrote: please see if you can review / test the change in https://gerrit.sqlalchemy.org/#/c/zzzeek/sqlalchemy/+/734. thanks! |
Michael Bayer (@zzzeek) wrote: Refactor "get" to allow for pluggable identity token schemes Fixed regression in 1.2 within sharded query feature where the Change-Id: I04fa60535deec2d0cdec89f602935dfebeb9eb9d → 43f2783 |
Michael Bayer (@zzzeek) wrote: Refactor "get" to allow for pluggable identity token schemes Fixed regression in 1.2 within sharded query feature where the Change-Id: I04fa60535deec2d0cdec89f602935dfebeb9eb9d → eee88f5 |
Changes by Michael Bayer (@zzzeek):
|
Rishi Sharma (@rishirishi) wrote: Tested on 1.2.7 locally and seeing the following error:
The reason being is that we have never implemented "id_chooser" (because we don't use "get" to fetch a single record, instead apply a filter on the primary key, then use "one" or "first"). I suppose the recent change in 1.2.7 now requires "id_chooser" to be implemented? |
Michael Bayer (@zzzeek) wrote: yeah the horizontal shard extension assumes you've implemented all three. in your case, this is easy, the "ident" passed has the existing shard as ident[-1], just return that in a list:
|
Rishi Sharma (@rishirishi) wrote: Using your implementation in my case, the ident is, for example, [1, 1] representing a composite primary key. The shard_id is not present in that list. |
Michael Bayer (@zzzeek) wrote: oh it's just giving you the identity, not the whole key :) OK , are you using your own ShardedQuery subclass? I can pass the parent state privately |
Rishi Sharma (@rishirishi) wrote: Yeah, we have subclassed ShardedQuery and passed that into sessionmaker as query_cls. |
Michael Bayer (@zzzeek) wrote: or you can search for that identity in the identity map locally to get it
the id_chooser() function should be enhanced so that it is given context for the identity it's being asked for. or a fourth, optional callable can be added to ShardedSession that is specifically for lazy loads. The latter is possibly more doable in a point release. |
Michael Bayer (@zzzeek) wrote: yeah that id chooser won't really work that great, because if the object is not locally present then you don't know the shard id unless we send you more information. |
Michael Bayer (@zzzeek) wrote: but....it should get you to where you were before? would be fully:
|
Rishi Sharma (@rishirishi) wrote: With a minor modification of your id_chooser we get back to where we were:
I wonder if there is a small performance hit in scanning the identity_map keys for 100s of lookups, in our case. Your suggestion of an "optional callable can be added to ShardedSession that is specifically for lazy loads" seems reasonable. Although we are eager, the upgrade is not urgent, so please feel to take the time to do what you think makes sense. |
Rishi Sharma (@rishirishi) wrote: Ah ok, I will follow #4243. Thanks! |
Michael Bayer (@zzzeek) wrote: Add unique_constraint_name to MSSQL FK reflection Fixed bug in MSSQL reflection where when two same-named tables in different Fixes: #4228 → ca94ea8 |
Michael Bayer (@zzzeek) wrote: Add unique_constraint_name to MSSQL FK reflection Fixed bug in MSSQL reflection where when two same-named tables in different Fixes: #4228 → ff2a296 |
Migrated issue, originally created by Rishi Sharma (@rishirishi)
SQLAlchemy >= 1.2
In sharded setups, the lazy loading strategy no longer fetches instances available in the identity map; instead, emits a query.
The following test passes in 1.1 but fails in 1.2
The text was updated successfully, but these errors were encountered: