tsdb/retention: remove file when ref's clear
This commit is contained in:
parent
e88fb84508
commit
386c25a99a
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tsdbFile2.h"
|
#include "tsdbFile2.h"
|
||||||
|
#include "cos.h"
|
||||||
|
|
||||||
// to_json
|
// to_json
|
||||||
static int32_t head_to_json(const STFile *file, cJSON *json);
|
static int32_t head_to_json(const STFile *file, cJSON *json);
|
||||||
|
@ -44,7 +45,17 @@ static const struct {
|
||||||
void remove_file(const char *fname) {
|
void remove_file(const char *fname) {
|
||||||
int32_t code = taosRemoveFile(fname);
|
int32_t code = taosRemoveFile(fname);
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("file:%s remove failed", fname);
|
if (tsS3Enabled) {
|
||||||
|
const char *object_name = taosDirEntryBaseName((char *)fname);
|
||||||
|
long s3_size = tsS3Enabled ? s3Size(object_name) : 0;
|
||||||
|
if (!strncmp(fname + strlen(fname) - 5, ".data", 5) && s3_size > 0) {
|
||||||
|
s3DeleteObjects(&object_name, 1);
|
||||||
|
} else {
|
||||||
|
tsdbError("file:%s remove failed", fname);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tsdbError("file:%s remove failed", fname);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("file:%s is removed", fname);
|
tsdbInfo("file:%s is removed", fname);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "cos.h"
|
||||||
#include "tsdb.h"
|
#include "tsdb.h"
|
||||||
#include "tsdbFS2.h"
|
#include "tsdbFS2.h"
|
||||||
#include "cos.h"
|
|
||||||
#include "vnd.h"
|
#include "vnd.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -292,15 +292,15 @@ static int32_t tsdbDoRetentionOnFileSet(SRTNer *rtner, STFileSet *fset) {
|
||||||
if (expLevel < 0) { // remove the fileset
|
if (expLevel < 0) { // remove the fileset
|
||||||
for (int32_t ftype = 0; (ftype < TSDB_FTYPE_MAX) && (fobj = fset->farr[ftype], 1); ++ftype) {
|
for (int32_t ftype = 0; (ftype < TSDB_FTYPE_MAX) && (fobj = fset->farr[ftype], 1); ++ftype) {
|
||||||
if (fobj == NULL) continue;
|
if (fobj == NULL) continue;
|
||||||
|
/*
|
||||||
int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs);
|
int32_t nlevel = tfsGetLevel(rtner->tsdb->pVnode->pTfs);
|
||||||
if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && fobj->f->did.level == nlevel - 1) {
|
if (tsS3Enabled && nlevel > 1 && TSDB_FTYPE_DATA == ftype && fobj->f->did.level == nlevel - 1) {
|
||||||
code = tsdbRemoveFileObjectS3(rtner, fobj);
|
code = tsdbRemoveFileObjectS3(rtner, fobj);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
} else {
|
} else {*/
|
||||||
code = tsdbDoRemoveFileObject(rtner, fobj);
|
code = tsdbDoRemoveFileObject(rtner, fobj);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSttLvl *lvl;
|
SSttLvl *lvl;
|
||||||
|
|
Loading…
Reference in New Issue