Fix error printing, stable column names
This commit is contained in:
parent
8fa0a94b62
commit
16f8b8e43f
@ -176,9 +176,18 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
|||||||
* Do not try to register a column that may already be registered
|
* Do not try to register a column that may already be registered
|
||||||
*/
|
*/
|
||||||
private long registerColumn(@NotNull ColumnInstance column) {
|
private long registerColumn(@NotNull ColumnInstance column) {
|
||||||
|
synchronized (columnEditLock) {
|
||||||
try {
|
try {
|
||||||
var columnName = new String(column.cfh().getName(), StandardCharsets.UTF_8);
|
var columnName = new String(column.cfh().getName(), StandardCharsets.UTF_8);
|
||||||
long id = FastRandomUtils.allocateNewValue(this.columns, column, 1, Long.MAX_VALUE);
|
long hashCode = columnName.hashCode();
|
||||||
|
long id;
|
||||||
|
if (this.columnNamesIndex.get(columnName) == hashCode) {
|
||||||
|
id = hashCode;
|
||||||
|
} else if (this.columns.get(hashCode) == null) {
|
||||||
|
id = hashCode;
|
||||||
|
} else {
|
||||||
|
id = FastRandomUtils.allocateNewValue(this.columns, column, 1, Long.MAX_VALUE);
|
||||||
|
}
|
||||||
Long previous = this.columnNamesIndex.putIfAbsent(columnName, id);
|
Long previous = this.columnNamesIndex.putIfAbsent(columnName, id);
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
//noinspection resource
|
//noinspection resource
|
||||||
@ -191,12 +200,14 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The column must be unregistered once!!!
|
* The column must be unregistered once!!!
|
||||||
* Do not try to unregister a column that may already be unregistered, or that may not be registered
|
* Do not try to unregister a column that may already be unregistered, or that may not be registered
|
||||||
*/
|
*/
|
||||||
private ColumnInstance unregisterColumn(long id) {
|
private ColumnInstance unregisterColumn(long id) {
|
||||||
|
synchronized (columnEditLock) {
|
||||||
var col = this.columns.remove(id);
|
var col = this.columns.remove(id);
|
||||||
Objects.requireNonNull(col, () -> "Column does not exist: " + id);
|
Objects.requireNonNull(col, () -> "Column does not exist: " + id);
|
||||||
String name;
|
String name;
|
||||||
@ -227,6 +238,7 @@ public class EmbeddedDB implements RocksDBSyncAPI, Closeable {
|
|||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
@ -542,8 +542,9 @@ public class GrpcServer extends Server {
|
|||||||
private <T> Function<Flux<T>, Flux<T>> onErrorMapFluxWithRequestInfo(String requestName, Message request) {
|
private <T> Function<Flux<T>, Flux<T>> onErrorMapFluxWithRequestInfo(String requestName, Message request) {
|
||||||
return flux -> flux.onErrorResume(throwable -> {
|
return flux -> flux.onErrorResume(throwable -> {
|
||||||
var ex = handleError(throwable).asException();
|
var ex = handleError(throwable).asException();
|
||||||
if (ex.getStatus().getCode() == Code.INTERNAL) {
|
if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable instanceof RocksDBException)) {
|
||||||
LOG.error("Unexpected internal error during request: {}", request, ex);
|
LOG.error("Unexpected internal error during request \"{}\": {}", requestName, request.toString(), ex);
|
||||||
|
return Mono.error(RocksDBException.of(RocksDBErrorType.INTERNAL_ERROR, ex.getCause()));
|
||||||
}
|
}
|
||||||
return Mono.error(ex);
|
return Mono.error(ex);
|
||||||
});
|
});
|
||||||
@ -552,7 +553,7 @@ public class GrpcServer extends Server {
|
|||||||
private <T> Function<Mono<T>, Mono<T>> onErrorMapMonoWithRequestInfo(String requestName, Message request) {
|
private <T> Function<Mono<T>, Mono<T>> onErrorMapMonoWithRequestInfo(String requestName, Message request) {
|
||||||
return flux -> flux.onErrorResume(throwable -> {
|
return flux -> flux.onErrorResume(throwable -> {
|
||||||
var ex = handleError(throwable).asException();
|
var ex = handleError(throwable).asException();
|
||||||
if (ex.getStatus().getCode() == Code.INTERNAL) {
|
if (ex.getStatus().getCode() == Code.INTERNAL && !(throwable instanceof RocksDBException)) {
|
||||||
LOG.error("Unexpected internal error during request \"{}\": {}", requestName, request.toString(), ex);
|
LOG.error("Unexpected internal error during request \"{}\": {}", requestName, request.toString(), ex);
|
||||||
return Mono.error(RocksDBException.of(RocksDBErrorType.INTERNAL_ERROR, ex.getCause()));
|
return Mono.error(RocksDBException.of(RocksDBErrorType.INTERNAL_ERROR, ex.getCause()));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user