in entity-store/src/main/java/jetbrains/exodus/entitystore/PersistentEntityStoreImpl.java [659:722]
public ArrayList<long[]> ensureBlobsConsistency(final PersistentStoreTransaction txn, boolean force) {
final ArrayList<long[]> result = new ArrayList<>();
try (Cursor entityTypesCursor = entityTypes.getTable().getSecondIndexCursor(txn.getEnvironmentTransaction())) {
while (entityTypesCursor.getNext()) {
final int entityTypeId = IntegerBinding.compressedEntryToInt(entityTypesCursor.getKey());
var blobsTable = getBlobsTable(txn, entityTypeId);
var store = blobsTable.getPrimaryIndex();
var envTransaction = txn.getEnvironmentTransaction();
try (var blobCursor = store.openCursor(envTransaction)) {
while (blobCursor.getNext()) {
var blobIterable = blobCursor.getValue();
var blobHandle = entryToBlobHandle(blobIterable);
if (!isEmptyOrInPlaceBlobHandle(blobHandle)) {
int counter = 0;
final int sleepInterval = 50;
final int counterMaxValue = config.getBlobMaxReadWaitingInterval() * 1000 / sleepInterval;
while (true) {
var blobLocation = blobVault.getBlobLocation(blobHandle);
var blobLength = getBlobFileLength(blobHandle, envTransaction);
if (blobLength == null || blobLocation.exists() && blobLocation.length() == blobLength) {
break;
}
if (counter > counterMaxValue) {
if (!blobLocation.exists()) {
throw new ExodusException("Blob file " + blobLocation.getAbsolutePath() +
" does not exist in expected location.");
}
var expectedBlobLength = getBlobFileLength(blobHandle, envTransaction).longValue();
if (blobLocation.length() != expectedBlobLength) {
throw new ExodusException("Blob file " + blobLocation.getAbsolutePath() +
" expected length is " + expectedBlobLength + " but actual is " +
blobLocation.length());
}
break;
}
if (force) {
counter++;
//noinspection BusyWait
Thread.sleep(sleepInterval);
} else {
var propertyKey = PropertyKey.entryToPropertyKey(blobCursor.getKey());
result.add(new long[]{entityTypeId, propertyKey.getEntityLocalId(), propertyKey.getPropertyId()});
break;
}
}
}
}
} catch (InterruptedException e) {
throw new ExodusException("Store : " + getName() + " - Execution of thread was interrupted", e);
}
}
}
return result;
}