forked from Qortal/qortal
Don't update statuses when processing arbitrary transactions, to improve success rate and speed it up.
This commit is contained in:
parent
537779b152
commit
d8237abde5
@ -86,6 +86,10 @@ public class ArbitraryDataCacheManager extends Thread {
|
|||||||
arbitraryTransaction.updateArbitraryMetadataCache(repository);
|
arbitraryTransaction.updateArbitraryMetadataCache(repository);
|
||||||
repository.saveChanges();
|
repository.saveChanges();
|
||||||
|
|
||||||
|
// Update status as separate commit, as this is more prone to failure
|
||||||
|
arbitraryTransaction.updateArbitraryResourceStatus(repository);
|
||||||
|
repository.saveChanges();
|
||||||
|
|
||||||
LOGGER.debug(() -> String.format("Finished processing transaction %.8s in arbitrary resource queue...", Base58.encode(transactionData.getSignature())));
|
LOGGER.debug(() -> String.format("Finished processing transaction %.8s in arbitrary resource queue...", Base58.encode(transactionData.getSignature())));
|
||||||
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
@ -168,11 +172,15 @@ public class ArbitraryDataCacheManager extends Thread {
|
|||||||
ArbitraryTransaction arbitraryTransaction = new ArbitraryTransaction(repository, transactionData);
|
ArbitraryTransaction arbitraryTransaction = new ArbitraryTransaction(repository, transactionData);
|
||||||
arbitraryTransaction.updateArbitraryResourceCache(repository);
|
arbitraryTransaction.updateArbitraryResourceCache(repository);
|
||||||
arbitraryTransaction.updateArbitraryMetadataCache(repository);
|
arbitraryTransaction.updateArbitraryMetadataCache(repository);
|
||||||
|
repository.saveChanges();
|
||||||
|
|
||||||
|
// Update status as separate commit, as this is more prone to failure
|
||||||
|
arbitraryTransaction.updateArbitraryResourceStatus(repository);
|
||||||
|
repository.saveChanges();
|
||||||
}
|
}
|
||||||
offset += batchSize;
|
offset += batchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
repository.saveChanges();
|
|
||||||
LOGGER.info("Completed build of arbitrary resources cache.");
|
LOGGER.info("Completed build of arbitrary resources cache.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,9 @@ public class ArbitraryTransaction extends Transaction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add/update arbitrary resource caches
|
// Add/update arbitrary resource caches, but don't update the status as this involves time-consuming
|
||||||
|
// disk reads, and is more prone to failure. The status will be updated on metadata retrieval, or when
|
||||||
|
// accessing the resource.
|
||||||
this.updateArbitraryResourceCache(repository);
|
this.updateArbitraryResourceCache(repository);
|
||||||
this.updateArbitraryMetadataCache(repository);
|
this.updateArbitraryMetadataCache(repository);
|
||||||
|
|
||||||
@ -408,6 +410,32 @@ public class ArbitraryTransaction extends Transaction {
|
|||||||
|
|
||||||
// Save
|
// Save
|
||||||
repository.getArbitraryRepository().save(arbitraryResourceData);
|
repository.getArbitraryRepository().save(arbitraryResourceData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateArbitraryResourceStatus(Repository repository) throws DataException {
|
||||||
|
// Don't cache resources without a name (such as auto updates)
|
||||||
|
if (arbitraryTransactionData.getName() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Service service = arbitraryTransactionData.getService();
|
||||||
|
String name = arbitraryTransactionData.getName();
|
||||||
|
String identifier = arbitraryTransactionData.getIdentifier();
|
||||||
|
|
||||||
|
if (service == null) {
|
||||||
|
// Unsupported service - ignore this resource
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the cache we store null identifiers as "default", as it is part of the primary key
|
||||||
|
if (identifier == null) {
|
||||||
|
identifier = "default";
|
||||||
|
}
|
||||||
|
|
||||||
|
ArbitraryResourceData arbitraryResourceData = new ArbitraryResourceData();
|
||||||
|
arbitraryResourceData.service = service;
|
||||||
|
arbitraryResourceData.name = name;
|
||||||
|
arbitraryResourceData.identifier = identifier;
|
||||||
|
|
||||||
// Update status
|
// Update status
|
||||||
ArbitraryDataResource resource = new ArbitraryDataResource(name, ArbitraryDataFile.ResourceIdType.NAME, service, identifier);
|
ArbitraryDataResource resource = new ArbitraryDataResource(name, ArbitraryDataFile.ResourceIdType.NAME, service, identifier);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user