fix:多线程场景下,文件锁失效

Signed-off-by: 邓俊 <dengjun39@huawei.com>
This commit is contained in:
邓俊 2024-11-08 20:12:33 +08:00
parent 71fa7555ab
commit bdc2a9f9a3

View File

@ -77,6 +77,7 @@ using RdbMgr = DistributedRdb::RdbManagerImpl;
static constexpr const char *BEGIN_TRANSACTION_SQL = "begin;";
static constexpr const char *COMMIT_TRANSACTION_SQL = "commit;";
static constexpr const char *ROLLBACK_TRANSACTION_SQL = "rollback;";
static constexpr const char *BACKUP_RESTORE = "backup.restore";
constexpr int64_t TIME_OUT = 1500;
void RdbStoreImpl::InitSyncerParam(const RdbStoreConfig &config, bool created)
@ -1429,7 +1430,7 @@ int RdbStoreImpl::Backup(const std::string &databasePath, const std::vector<uint
return ret;
}
RdbSecurityManager::KeyFiles keyFiles(backupFilePath);
RdbSecurityManager::KeyFiles keyFiles(path_ + BACKUP_RESTORE);
keyFiles.Lock();
auto deleteDirtyFiles = [&backupFilePath] {
@ -2196,10 +2197,10 @@ int RdbStoreImpl::Restore(const std::string &backupPath, const std::vector<uint8
return E_ERROR;
}
RdbSecurityManager::KeyFiles keyFiles(path_ + BACKUP_RESTORE);
keyFiles.Lock();
std::string destPath;
bool isOK = TryGetMasterSlaveBackupPath(backupPath, destPath, true);
RdbSecurityManager::KeyFiles keyFiles(destPath);
keyFiles.Lock();
if (!isOK) {
int ret = GetDestPath(backupPath, destPath);
if (ret != E_OK) {