Browse Source

Yet another attempt to optimize the online accounts import queue processing.

The main difference here is that we now remove items from the onlineAccountsImportQueue in a batch, _after_ they have been imported. This prevents duplicates from being added to the queue in the previous time gap between them being removed and imported.
pull/97/head
CalDescent 2 years ago
parent
commit
765416db71
  1. 13
      src/main/java/org/qortal/controller/OnlineAccountsManager.java

13
src/main/java/org/qortal/controller/OnlineAccountsManager.java

@ -207,13 +207,20 @@ public class OnlineAccountsManager {
boolean isValid = this.isValidCurrentAccount(repository, onlineAccountData); boolean isValid = this.isValidCurrentAccount(repository, onlineAccountData);
if (isValid) if (isValid)
addAccounts(Arrays.asList(onlineAccountData)); onlineAccountsToAdd.add(onlineAccountData);
// Remove from queue // Don't remove from the queue yet - we'll do this at the end of the process
onlineAccountsImportQueue.remove(onlineAccountData); // This prevents duplicates being added to the queue whilst it's being processed
} }
} catch (DataException e) { } catch (DataException e) {
LOGGER.error("Repository issue while verifying online accounts", e); LOGGER.error("Repository issue while verifying online accounts", e);
} finally {
if (!onlineAccountsToAdd.isEmpty()) {
LOGGER.debug("Merging {} validated online accounts from import queue", onlineAccountsToAdd.size());
addAccounts(onlineAccountsToAdd);
onlineAccountsImportQueue.removeAll(onlineAccountsToAdd);
}
} }
} }

Loading…
Cancel
Save