Fix some small transactional issues in SQL mode (#1662)

* Fix some small transactional issues in SQL mode

These weren't caught until I switched the default database type in tests
to be SQL (separate PR). Fortunately these don't seem to be catastrophic
This commit is contained in:
gbrodman
2022-06-09 15:01:34 -04:00
committed by GitHub
parent 623356b1e8
commit e30b3f9e0b
4 changed files with 38 additions and 30 deletions
@@ -49,11 +49,14 @@ final class GetAllocationTokenCommand implements CommandWithRemoteApi {
tokens.stream()
.map(t -> VKey.create(AllocationToken.class, t))
.collect(toImmutableList());
tm().loadByKeysIfPresent(tokenKeys)
.forEach((k, v) -> builder.put(k.getSqlKey().toString(), v));
tm().transact(
() ->
tm().loadByKeysIfPresent(tokenKeys)
.forEach((k, v) -> builder.put(k.getSqlKey().toString(), v)));
}
ImmutableMap<String, AllocationToken> loadedTokens = builder.build();
ImmutableMap<VKey<DomainBase>, DomainBase> domains = loadRedeemedDomains(loadedTokens.values());
ImmutableMap<VKey<DomainBase>, DomainBase> domains =
tm().transact(() -> loadRedeemedDomains(loadedTokens.values()));
for (String token : mainParameters) {
if (loadedTokens.containsKey(token)) {
@@ -204,7 +204,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
private ImmutableSortedSet<String> getExistingNameservers(DomainBase domain) {
ImmutableSortedSet.Builder<String> nameservers = ImmutableSortedSet.naturalOrder();
for (HostResource host : tm().loadByKeys(domain.getNameservers()).values()) {
for (HostResource host :
tm().transact(() -> tm().loadByKeys(domain.getNameservers()).values())) {
nameservers.add(host.getForeignKey());
}
return nameservers.build();