Skip to content

Commit

Permalink
fix: 修复sqlserver一些小问题 #7002
Browse files Browse the repository at this point in the history
  • Loading branch information
yksitu authored and iSecloud committed Sep 20, 2024
1 parent cbbe8aa commit 73276af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *SysInitParam) PreCheck() error {
if err != nil {
return err
}
if mem.Total < 2*1024*1024*2024 {
if mem.Total < 2*1024*1024*1024 {
return fmt.Errorf("system memory does not exceed 2GB")
}
logger.Info("System memory exceed 2GB, pass")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ var (
END
CREATE USER ['+@username+'] FOR LOGIN ['+@username+']
EXEC sp_addrolemember N''db_datareader'', N'''+@username+'''
USE [master]
GRANT VIEW ANY DEFINITION TO ['+@username+']
USE [Monitor]
IF EXISTS (SELECT * FROM sys.sysusers WHERE name = '''+@username+''')
BEGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3036,12 +3036,6 @@ BEGIN
@SHRINK_SIZE BIGINT,
@ERROR_MESSAGE VARCHAR(4000)

IF @BACKUP_ID=''
BEGIN
SET @BACKUP_ID=CONVERT(VARCHAR(36),NEWID())
END


--获取备份配置数据
SELECT @APP = APP,
@FULL_BACKUP_PATH = FULL_BACKUP_PATH,
Expand Down Expand Up @@ -3074,7 +3068,16 @@ BEGIN
@SHRINK_SIZE=ISNULL(SHRINK_SIZE,200)
FROM DBO.APP_SETTING

IF @DATA_SCHEMA_GRANT<>'ALL'
IF @BACKUP_ID=''
BEGIN
SET @BACKUP_ID=CONVERT(VARCHAR(36),NEWID())
END
ELSE
BEGIN
SET @DATA_SCHEMA_GRANT='all'
END

IF @DATA_SCHEMA_GRANT<>'all'
return

IF @BACKUP_FILETAG<>''
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/backend/db_services/sqlserver/rollback/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def query_binlogs(self, start_time: datetime, end_time: datetime, dbname: str):
@param end_time: 查询结束时间
@param dbname: 查询db
"""
# 单独获取最后一个binlog
# 单独获取最后一个binlog, 加1秒为了保证获取比时间点大于的日志备份
last_binlogs = self._get_log_from_bklog(
collector="mssql_binlog_result",
start_time=end_time,
start_time=end_time + timedelta(seconds=1),
end_time=end_time + timedelta(days=BACKUP_LOG_RANGE_DAYS),
query_string=f"""cluster_id: {self.cluster.id} AND dbname: "{dbname}" """,
size=1,
Expand All @@ -55,7 +55,7 @@ def query_binlogs(self, start_time: datetime, end_time: datetime, dbname: str):
binlogs = self._get_log_from_bklog(
collector="mssql_binlog_result",
start_time=start_time,
end_time=end_time,
end_time=end_time + timedelta(seconds=1),
query_string=f"""cluster_id: {self.cluster.id} AND dbname: "{dbname}" """,
)
# TODO: binlog是否需要聚合 or 转义
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def format_ticket_data(self):
# 获取最近的一次日志备份记录的时间点
last_time = str2datetime(SQLServerRollbackHandler(cluster_id).query_last_log_time(current_time))
# 如果最近一次日志备份记录的时间大于等于回滚时间 则不需要备份
if last_time >= restore_time:
if last_time > restore_time:
continue

backup_dbs = ClusterServiceHandler(self.ticket.bk_biz_id).get_dbs_for_drs(
Expand Down

0 comments on commit 73276af

Please sign in to comment.