diff --git a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestLogInterceptor.java b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestLogInterceptor.java index f637c04023..382c80a4e1 100644 --- a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestLogInterceptor.java +++ b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestLogInterceptor.java @@ -36,7 +36,7 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttp ODCRestContext odcRestContext = OdcRestTemplate.get(); Verify.notNull(odcRestContext, "odcRestContext"); odcRestContext.setRealUrl(request.getURI().toString()); - log.info("start call rest {} , method:{} , URL:{}", odcRestContext.getApiName(), request.getMethod(), + log.debug("start call rest {} , method:{} , URL:{}", odcRestContext.getApiName(), request.getMethod(), request.getURI()); return execution.execute(request, body); } diff --git a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestTemplate.java b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestTemplate.java index 0bc21b3926..baa9eaa06e 100644 --- a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestTemplate.java +++ b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/rest/OdcRestTemplate.java @@ -85,18 +85,18 @@ protected T doExecute(URI url, @Nullable HttpMethod method, @Nullable Reques T res = super.doExecute(url, method, requestCallback, responseExtractor); ODCRestContext context = API_CALL_LOG_PREFIX.get(); if (context.getLogResponseEnabled()) { - log.info("success call rest {}, url={}, response={}, cost={}ms", context.getApiName(), + log.debug("success call rest {}, url={}, response={}, cost={}ms", context.getApiName(), context.getRealUrl(), res, context.getExecTime()); } else { - log.info("success call rest {}, url={}, cost={}ms", context.getApiName(), + log.debug("success call rest {}, url={}, cost={}ms", context.getApiName(), context.getRealUrl(), context.getExecTime()); } return res; } catch (Exception e) { ODCRestContext context = API_CALL_LOG_PREFIX.get(); - log.error("failed call rest {}, URL:{}, cost={} ms ", context.getApiName(), context.getRealUrl(), + log.debug("failed call rest {}, URL:{}, cost={} ms ", context.getApiName(), context.getRealUrl(), context.getExecTime(), e); throw new UnexpectedException("Internal service call failed, please contact support team"); } finally { diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/DatabaseSyncSchedules.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/DatabaseSyncSchedules.java index 5b495e2fec..b7015635a0 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/DatabaseSyncSchedules.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/DatabaseSyncSchedules.java @@ -52,9 +52,9 @@ public void syncDatabases() { try { SecurityContextUtils.setCurrentUser(connection.getCreatorId(), connection.getOrganizationId(), null); databaseSyncManager.syncDataSource(connection.getId()); - log.info("sync datasource successfully, connectionId={}", connection.getId()); + log.debug("sync datasource successfully, connectionId={}", connection.getId()); } catch (Exception ex) { - log.warn("sync datasource failed, datasourceId={}", connection.getId(), ex); + log.debug("sync datasource failed, datasourceId={}", connection.getId(), ex); } } } diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java index c2698ec7fe..bed23de4d4 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.concurrent.TimeUnit; @@ -60,6 +61,8 @@ import com.oceanbase.odc.core.shared.exception.BadRequestException; import com.oceanbase.odc.core.shared.exception.ConflictException; import com.oceanbase.odc.core.shared.exception.NotFoundException; +import com.oceanbase.odc.metadb.connection.ConnectionConfigRepository; +import com.oceanbase.odc.metadb.connection.ConnectionEntity; import com.oceanbase.odc.metadb.connection.DatabaseEntity; import com.oceanbase.odc.metadb.connection.DatabaseRepository; import com.oceanbase.odc.metadb.connection.DatabaseSpecs; @@ -133,6 +136,9 @@ public class DatabaseService { @Autowired private HorizontalDataPermissionValidator horizontalDataPermissionValidator; + @Autowired + private ConnectionConfigRepository connectionConfigRepository; + @Transactional(rollbackFor = Exception.class) @SkipAuthorize("internal authenticated") public Database detail(@NonNull Long id) { @@ -367,14 +373,17 @@ public Boolean internalSyncDataSourceSchemas(@NonNull Long dataSourceId) throws } ConnectionSession connectionSession = null; try { - if (!connectionService.existsById(dataSourceId)) { + Optional connectionOpt = connectionConfigRepository.findById(dataSourceId); + if (!connectionOpt.isPresent()) { return false; } - ConnectionConfig connection = connectionService.getForConnectionSkipPermissionCheck(dataSourceId); - if (connection.getEnvironmentId().longValue() == -1L - || connection.getVisibleScope() == ConnectionVisibleScope.PRIVATE) { + ConnectionEntity saved = connectionOpt.get(); + if (saved.getEnvironmentId().longValue() == -1L + || saved.getVisibleScope() == ConnectionVisibleScope.PRIVATE) { return false; } + + ConnectionConfig connection = connectionService.getForConnectionSkipPermissionCheck(dataSourceId); horizontalDataPermissionValidator.checkCurrentOrganization(connection); DefaultConnectSessionFactory factory = new DefaultConnectSessionFactory(connection); connectionSession = factory.generateSession();