DBCC SHRINKFILE 会终止活动事务吗?

Will DBCC SHRINKFILE kill the active transaction?

我创建了一个作业,每天将数 GB 的数据从源数据库加载到目标数据库。一开始这项工作 运行 没有任何问题。

过去 2 周作业失败,因为事务日志已满。

我在我的 SQl 作业中添加了一个步骤来在加载开始前清除日志,但仍然发生同样的错误。

我监测到最后一个 table 在出错前正在加载,等待几分钟才失败。我怀疑它正在等待清理日志。

如果我在作业当前 运行ning 时在此数据库上 运行 DBCC SHRINKFILE 命令,它是否也会擦除 out/kill 活动事务?

If I run the DBCC SHRINKFILE command on this DB when the job is currently running, will it wipe out/kill the active transaction as well

不,DBCC SHRINKFILE 不会终止事务

I've added a step in my SQL job to clear the log before the loading starts.

如果您正在缩小文件,并且没有空闲 space,这不会 clearshrink 日志文件。你需要 backup the log file, ideally somewhat frequently based on your RPO and RTO, or swap your recovery model during this bulk insert to something like BULK LOGGED. More on how to do TLOG backups.