Fix observed mismatches by swapping in original UUID
This commit is contained in:
parent
282f39141e
commit
30b2c2b5ad
|
@ -118,12 +118,25 @@ public class AccountsManager {
|
||||||
|
|
||||||
public boolean create(Account account) {
|
public boolean create(Account account) {
|
||||||
try (Timer.Context ignored = createTimer.time()) {
|
try (Timer.Context ignored = createTimer.time()) {
|
||||||
|
final UUID originalUuid = account.getUuid();
|
||||||
boolean freshUser = databaseCreate(account);
|
boolean freshUser = databaseCreate(account);
|
||||||
redisSet(account);
|
|
||||||
|
|
||||||
|
// databaseCreate() sometimes updates the UUID, if there was a number conflict.
|
||||||
|
// for metrics, we want dynamo to run with the same original UUID
|
||||||
|
final UUID actualUuid = account.getUuid();
|
||||||
|
|
||||||
|
try {
|
||||||
if (dynamoWriteEnabled()) {
|
if (dynamoWriteEnabled()) {
|
||||||
|
|
||||||
|
account.setUuid(originalUuid);
|
||||||
|
|
||||||
runSafelyAndRecordMetrics(() -> dynamoCreate(account), Optional.of(account.getUuid()), freshUser,
|
runSafelyAndRecordMetrics(() -> dynamoCreate(account), Optional.of(account.getUuid()), freshUser,
|
||||||
(databaseResult, dynamoResult) -> {
|
(databaseResult, dynamoResult) -> {
|
||||||
|
|
||||||
|
if (!account.getUuid().equals(actualUuid)) {
|
||||||
|
logger.warn("dynamoCreate() did not return correct UUID");
|
||||||
|
}
|
||||||
|
|
||||||
if (databaseResult.equals(dynamoResult)) {
|
if (databaseResult.equals(dynamoResult)) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -136,6 +149,12 @@ public class AccountsManager {
|
||||||
},
|
},
|
||||||
"create");
|
"create");
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
account.setUuid(actualUuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisSet(account);
|
||||||
|
|
||||||
return freshUser;
|
return freshUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue