diff --git a/include/util/taoserror.h b/include/util/taoserror.h index ce8db162b6..0256a496df 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -124,6 +124,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_INVALID_CFG_VALUE TAOS_DEF_ERROR_CODE(0, 0x0133) #define TSDB_CODE_IP_NOT_IN_WHITE_LIST TAOS_DEF_ERROR_CODE(0, 0x0134) +#define TSDB_CODE_FAILED_TO_CONNECT_S3 TAOS_DEF_ERROR_CODE(0, 0x0135) //client #define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 1dca5eda9b..2a334a34b8 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -891,6 +891,8 @@ long s3Size(const char *object_name) { if ((cbd.status != S3StatusOK) && (cbd.status != S3StatusErrorPreconditionFailed)) { s3PrintError(__FILE__, __LINE__, __func__, cbd.status, cbd.err_msg); + + return -1; } size = cbd.content_length; diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 217df923ef..d36d15f9b4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -26,7 +26,17 @@ static int32_t tsdbOpenFileImpl(STsdbFD *pFD) { if (pFD->pFD == NULL) { int errsv = errno; const char *object_name = taosDirEntryBaseName((char *)path); - long s3_size = tsS3Enabled ? s3Size(object_name) : 0; + long s3_size = 0; + if (tsS3Enabled) { + long size = s3Size(object_name); + if (size < 0) { + code = terrno = TSDB_CODE_FAILED_TO_CONNECT_S3; + goto _exit; + } + + s3_size = size; + } + if (tsS3Enabled && !strncmp(path + strlen(path) - 5, ".data", 5) && s3_size > 0) { #ifndef S3_BLOCK_CACHE s3EvictCache(path, s3_size); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f310db53ef..8847b7d894 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -101,6 +101,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_APP_IS_STOPPING, "Database is closing d TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_DATA_FMT, "Invalid data format") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_CFG_VALUE, "Invalid configuration value") TAOS_DEFINE_ERROR(TSDB_CODE_IP_NOT_IN_WHITE_LIST, "Not allowed to connect") +TAOS_DEFINE_ERROR(TSDB_CODE_FAILED_TO_CONNECT_S3, "Failed to connect to s3 server") //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation")