Skip to content

Commit

Permalink
fix-comp-checker: move try from transaction in YdbDataCompatibilityCh…
Browse files Browse the repository at this point in the history
…ecker
  • Loading branch information
Alexander Lavrukov authored and nvamelichev committed Mar 6, 2024
1 parent 4c8d901 commit b730b7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public <T extends Entity<T>> Table<T> table(Class<T> c) {
@Override
public void commit() {
if (isBadSession) {
throw new IllegalStateException("Transaction was invalidated. Commit isn't possible");
log.error("Transaction was invalidated, but exception was omitted. Commit must not be called after error");
}
try {
flushPendingWrites();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ public void run() {
}
stream.forEach(ec -> {
log.info(format("Checking entities of %s", ec.getSimpleName()));
txManager.readOnly().noFirstLevelCache()
.run(() -> {
Stopwatch sw = Stopwatch.createStarted();
RepositoryTransaction tx = Tx.Current.get().getRepositoryTransaction();
try {
@SuppressWarnings("unchecked")
long checkedCount = tx.table(ec).readTable(params).count();
Stopwatch sw = Stopwatch.createStarted();
try {
txManager.readOnly().noFirstLevelCache().run(() -> {
RepositoryTransaction tx = Tx.Current.get().getRepositoryTransaction();

log.info(format("[%s] Checked %d entities of %s", sw, checkedCount, ec.getSimpleName()));
} catch (Exception e) {
String message = format("[%s] Got exception while checking entities of %s: ", sw, ec.getSimpleName());
if (config.skipSchemaErrors && e instanceof YdbSchemaException) {
log.warn(message);
} else {
log.error(message);
throw e;
}
}
});
@SuppressWarnings("unchecked")
long checkedCount = tx.table(ec).readTable(params).count();

log.info(format("[%s] Checked %d entities of %s", sw, checkedCount, ec.getSimpleName()));
});
} catch (Exception e) {
String message = format("[%s] Got exception while checking entities of %s: ", sw, ec.getSimpleName());
if (config.skipSchemaErrors && e instanceof YdbSchemaException) {
log.warn(message);
} else {
log.error(message);
throw e;
}
}
});
log.info(format("[%s] Data compatibility checked successfully", totalTime));
}
Expand Down

0 comments on commit b730b7b

Please sign in to comment.