diff --git a/src/flb_storage.c b/src/flb_storage.c index 24cb79b6cdb..4148be66781 100644 --- a/src/flb_storage.c +++ b/src/flb_storage.c @@ -532,6 +532,22 @@ int flb_storage_input_create(struct cio_ctx *cio, return -1; } } + else if (stream->type != cio_storage_type) { + flb_debug("[storage] storage type mismatch. input type=%s", + flb_storage_get_type(in->storage_type)); + if (stream->type == FLB_STORAGE_FS) { + flb_warn("[storage] Need to remove '%s/%s' if it is empty", cio->options.root_path, in->name); + } + + cio_stream_destroy(stream); + stream = cio_stream_create(cio, in->name, cio_storage_type); + if (!stream) { + flb_error("[storage] cannot create stream for instance %s", + in->name); + return -1; + } + flb_info("[storage] re-create stream type=%s", flb_storage_get_type(in->storage_type)); + } /* allocate storage context for the input instance */ si = flb_malloc(sizeof(struct flb_storage_input));