Skip to content

Commit

Permalink
Fix upon feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Emelia Lei <[email protected]>
  • Loading branch information
emelialei88 committed Jan 16, 2025
1 parent d7ac608 commit d932b99
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <mqbc_clusterstateledgerutil.h>
#include <mqbc_incoreclusterstateledgeriterator.h>
#include <mqbnet_cluster.h>
#include <mqbs_filestoreprintutil.h>
#include <mqbs_filestoreprotocol.h>
#include <mqbs_storageutil.h>
#include <mqbsi_log.h>
Expand Down Expand Up @@ -220,17 +219,17 @@ int IncoreClusterStateLedger::cleanupLog(const bsl::string& logPath)

const bsl::string& cluster = d_clusterData_p->cluster().name();

int rc = bdls::FilesystemUtil::remove(logPath);
const int rc = bdls::FilesystemUtil::remove(logPath);
if (0 != rc) {
BMQTSK_ALARMLOG_ALARM("FILE_IO")
<< cluster << ": Failed to remove [" << logPath
<< "] file during log file cleanup, rc: " << rc
<< "] file during CSL file cleanup, rc: " << rc
<< BMQTSK_ALARMLOG_END;
return rc_REMOVE_FILE_FAILURE;
return rc_REMOVE_FILE_FAILURE; // RETURN
}

BALL_LOG_INFO << cluster << ": Removed file [" << logPath
<< "] during log file cleanup";
<< "] during CSL file cleanup";

return rc_SUCCESS;
}
Expand Down
6 changes: 4 additions & 2 deletions src/groups/mqb/mqbsl/mqbsl_ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,15 @@ void Ledger::closeAndCleanup(const LogSp& log)

int rc = log->close();
if (rc != LogOpResult::e_SUCCESS) {
BALL_LOG_ERROR << "Failed to close the log " << logPath;
BALL_LOG_ERROR << "Failed to close the log " << logPath
<< ", rc: " << rc;
return; // RETURN
}

rc = d_config.cleanupCallback()(logPath);
if (rc != 0) {
BALL_LOG_ERROR << "Failed to clean up the log " << logPath;
BALL_LOG_ERROR << "Failed to clean up the log " << logPath
<< ", rc: " << rc;
return; // RETURN
}

Expand Down
13 changes: 9 additions & 4 deletions src/integration-tests/test_csl_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
from blazingmq.dev.it.fixtures import ( # pylint: disable=unused-import
Cluster,
cluster,
order,
tweak,
)
import glob

pytestmark = order(2)
timeout = 10


@tweak.cluster.partition_config.max_qlist_file_size(2000)
def test_csl_cleanup(cluster: Cluster):
leader = cluster.last_known_leader
proxy = next(cluster.proxy_cycle())

writer = proxy.create_client("writers")
producer = proxy.create_client("producer")

cluster._logger.info("Start to write to clients")

Expand All @@ -39,17 +43,18 @@ def test_csl_cleanup(cluster: Cluster):
)
assert len(csl_files_before_rollover) == 1

# opening 10 queues would cause a rollover
for i in range(0, 10):
writer.open(
producer.open(
f"bmq://{tc.DOMAIN_PRIORITY_SC}/q{i}", flags=["write,ack"], succeed=True
)
writer.close(f"bmq://{tc.DOMAIN_PRIORITY_SC}/q{i}", succeed=True)
producer.close(f"bmq://{tc.DOMAIN_PRIORITY_SC}/q{i}", succeed=True)

csl_files_after_rollover = glob.glob(
str(cluster.work_dir.joinpath(leader.name, "storage")) + "/*csl*"
)

assert leader.outputs_regex(r"Log closed and cleaned up. Time taken")
assert leader.outputs_regex(r"Log closed and cleaned up. Time taken", timeout)

assert len(csl_files_after_rollover) == 1
assert csl_files_before_rollover[0] != csl_files_after_rollover[0]

0 comments on commit d932b99

Please sign in to comment.