问题描述
我有一台装有Hangfire的服务器.我已经有一段时间没有检查过了,看来一项经常性工作已经变得很无赖.它停止工作,然后重试堆积,看起来似乎完全锁住了.
I have a server with Hangfire installed. I haven't checked it for a while and it seems one recurring job has gone rogue. It stopped working and then it has stacked up with retries resulting in a complete lock it seems.
我想清除数据库并重新开始.我可以只删除所有表中的数据,还是应该删除表并让Hangfire为我重新创建它们?我这样做会冒险吗?
I would like to clear my database and start over. Can i just delete the data from all tables or should I drop the tables and let Hangfire recreate them for me? Am I risking anything by doing this?
Hangfire.State使用整个Azure Basic数据库2GB的空间.
Hangfire.State using entire Azure Basic database 2GB of space.
推荐答案
我最终删除了表,起初查询根本不起作用,只是继续进行而没有任何反应.然后,我使用了TRUNCATE TABLE [HangFire].[State]
,此后一切都像灵符一样工作.这是我用于Hangfire 1.5.6
和UseSqlServerStorage
的脚本:
I ended up dropping the tables, at first the query did not work at all, it just kept going and nothing happened. I then used TRUNCATE TABLE [HangFire].[State]
and it all worked like a charm after. Here is the script I used for Hangfire 1.5.6
with UseSqlServerStorage
:
GO
PRINT N'Dropping [HangFire].[FK_HangFire_State_Job]...';
GO
ALTER TABLE [HangFire].[State] DROP CONSTRAINT [FK_HangFire_State_Job];
GO
PRINT N'Dropping [HangFire].[FK_HangFire_JobParameter_Job]...';
GO
ALTER TABLE [HangFire].[JobParameter] DROP CONSTRAINT [FK_HangFire_JobParameter_Job];
GO
PRINT N'Dropping [HangFire].[Schema]...';
GO
DROP TABLE [HangFire].[Schema];
GO
PRINT N'Dropping [HangFire].[Job]...';
GO
DROP TABLE [HangFire].[Job];
GO
PRINT N'Dropping [HangFire].[State]...';
GO
DROP TABLE [HangFire].[State];
GO
PRINT N'Dropping [HangFire].[JobParameter]...';
GO
DROP TABLE [HangFire].[JobParameter];
GO
PRINT N'Dropping [HangFire].[JobQueue]...';
GO
DROP TABLE [HangFire].[JobQueue];
GO
PRINT N'Dropping [HangFire].[Server]...';
GO
DROP TABLE [HangFire].[Server];
GO
PRINT N'Dropping [HangFire].[List]...';
GO
DROP TABLE [HangFire].[List];
GO
PRINT N'Dropping [HangFire].[Set]...';
GO
DROP TABLE [HangFire].[Set];
GO
PRINT N'Dropping [HangFire].[Counter]...';
GO
DROP TABLE [HangFire].[Counter];
GO
PRINT N'Dropping [HangFire].[Hash]...';
GO
DROP TABLE [HangFire].[Hash];
GO
PRINT N'Dropping [HangFire].[AggregatedCounter]...';
GO
DROP TABLE [HangFire].[AggregatedCounter];
GO
PRINT N'Dropping [HangFire]...';
GO
DROP SCHEMA [HangFire];
GO
PRINT N'Update complete.';
GO
这篇关于如何安全地将Hangfire重置为干净状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!