Skip to content
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

Wrong limit using setMaxRows on delete between calls #3183

Closed
AntoineDuComptoirDesPharmacies opened this issue Aug 22, 2023 · 0 comments · Fixed by #3186
Closed

Wrong limit using setMaxRows on delete between calls #3183

AntoineDuComptoirDesPharmacies opened this issue Aug 22, 2023 · 0 comments · Fixed by #3186
Assignees
Labels
Milestone

Comments

@AntoineDuComptoirDesPharmacies

Expected behavior

When limiting the number of rows in delete query, if the limit change between call, the query should adapt and only delete the good number of items.

Actual behavior

When calling the same method with different limit, the limit is taken into account only on first call and then reused between calls.

Steps to reproduce

DB.find(ShoppingCart.class)
                    .where()
                    [...]
                    .setMaxRows(nbProcessed)
                    .delete();

First call with nbProcessed = 20 :

application-akka.actor.default-dispatcher-31 - [info] - service.MaidService - nbProcessed : 20
application-akka.actor.default-dispatcher-31 - [debug] - io.ebean.SQL - txn[] select sc.id from shopping_cart sc where [...] limit 20; --bind(2023-07-22 13:09:10.837) --micros(4�187)
application-akka.actor.default-dispatcher-31 - [debug] - io.ebean.SQL - txn[] delete from shopping_cart where id  = any(?); -- bind(Array[20]={12032,12035,12042,12044,12057,12059,12060,...}) rows(20)
application-akka.actor.default-dispatcher-31 - [info] - service.JobService - cleanOrphanShoppingCart: 20 Rows cleaned

Second call with nbProcessed = 18 :

application-akka.actor.default-dispatcher-32 - [info] - service.MaidService - nbProcessed : 18
application-akka.actor.default-dispatcher-32 - [debug] - io.ebean.SQL - txn[] select sc.id from shopping_cart sc where [...] limit 20; --bind(2023-07-22 13:09:15.76) --micros(3�541)
application-akka.actor.default-dispatcher-32 - [debug] - io.ebean.SQL - txn[] delete from shopping_cart where id  = any(?); -- bind(Array[20]={12409,12427,12447,12448,12454,12467,12469,...}) rows(20)
application-akka.actor.default-dispatcher-32 - [info] - service.JobService - cleanOrphanShoppingCart: 20 Rows cleaned

Yours faithfully,
LCDP

rbygrave added a commit that referenced this issue Aug 24, 2023
Reproduces when the delete needs to perform a select due to caching or
cascading of the delete
@rbygrave rbygrave self-assigned this Aug 24, 2023
@rbygrave rbygrave added the bug label Aug 24, 2023
@rbygrave rbygrave added this to the 13.22.0 milestone Aug 24, 2023
rbygrave added a commit that referenced this issue Aug 24, 2023
#3183 - Fix for: Wrong limit using setMaxRows on delete between calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants