mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Filter in SQL when updating/deleting alloc tokens (#2244)
This doesn't fix any issues with dead/livelocks when deleting or updating allocation tokens, but it at least will significantly reduce the time to load the tokens that we'll want to update/delete.
This commit is contained in:
parent
dd86c56ddc
commit
cc9b3f5965
1 changed files with 6 additions and 3 deletions
|
@ -67,9 +67,12 @@ abstract class UpdateOrDeleteAllocationTokensCommand extends ConfirmingCommand {
|
||||||
checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank");
|
checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank");
|
||||||
return tm().transact(
|
return tm().transact(
|
||||||
() ->
|
() ->
|
||||||
tm().loadAllOf(AllocationToken.class).stream()
|
tm().query(
|
||||||
.filter(token -> token.getToken().startsWith(prefix))
|
"SELECT token FROM AllocationToken WHERE token LIKE :prefix",
|
||||||
.map(AllocationToken::createVKey)
|
String.class)
|
||||||
|
.setParameter("prefix", String.format("%s%%", prefix))
|
||||||
|
.getResultStream()
|
||||||
|
.map(token -> VKey.create(AllocationToken.class, token))
|
||||||
.collect(toImmutableList()));
|
.collect(toImmutableList()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue