Open Closed

Issue abp 8.2 + hangfire + sql: String or binary data would be truncated #7459


User avatar
0

I'm using abp+hangfire using SQL, but it looks like there's an issue related to the RecurringJobId length and the general constraint that Hangfire has on the Key column (nvarchar 100).

  • ABP Framework version: v8.2
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes, tiered
  • Exception message and full stack trace: (below)
  • Steps to reproduce the issue:

[2024-07-04 15:21:31.520] [Fatal] DEV1-PC () <> Host terminated unexpectedly! Error: "An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.Identity.AbpIdentityProDomainModule, Volo.Abp.Identity.Pro.Domain, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null: String or binary data would be truncated in table 'CabMD15.HangFire.Hash', column 'Key'. Truncated value: 'recurring-job:HangfirePeriodicBackgroundWorkerAdapter<IdentitySessionCleanupBackgroundWorker>.DoWork'.. See the inner exception for details." Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.Identity.AbpIdentityProDomainModule, Volo.Abp.Identity.Pro.Domain, Version=8.2.0.0, Culture=neutral, PublicKeyToken=null: String or binary data would be truncated in table 'CabMD15.HangFire.Hash', column 'Key'. Truncated value: 'recurring-job:HangfirePeriodicBackgroundWorkerAdapter<IdentitySessionCleanupBackgroundWorker>.DoWork'.. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated in table 'CabMD15.HangFire.Hash', column 'Key'. Truncated value: 'recurring-job:HangfirePeriodicBackgroundWorkerAdapter<IdentitySessionCleanupBackgroundWorker>.DoWork'. at void Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction) at void Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction) at void Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose) at bool Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, out bool dataReady) at void Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, string resetOptionsString, bool isInternal, bool forDescribeParameterEncryption, bool shouldCacheForAlwaysEncrypted) at SqlDataReader Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, bool returnStream, bool isAsync, int timeout, out Task task, bool asyncWrite, bool inRetry, SqlDataReader ds, bool describeParameterEncryptionRequest) at SqlDataReader Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, bool returnStream, TaskCompletionSource<object> completion, int timeout, out Task task, out bool usedCache, bool asyncWrite, bool inRetry, string method) at Task Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource<object> completion, bool sendToPipe, int timeout, out bool usedCache, bool asyncWrite, bool inRetry, string methodName) at int Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery() at void Hangfire.SqlServer.SqlCommandBatch.ExecuteNonQuery() in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlCommandBatch.cs:line 122 at void Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit()+(DbConnection connection, DbTransaction transaction) => { } in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerWriteOnlyTransaction.cs:line 100 at void Hangfire.SqlServer.SqlServerStorage.UseTransaction(DbConnection dedicatedConnection, Action<DbConnection, DbTransaction> action)+(DbConnection connection, DbTransaction transaction) => { } in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerStorage.cs:line 272 at void Hangfire.SqlServer.SqlServerStorage.UseTransaction(DbConnection dedicatedConnection, Action<DbConnection, DbTransaction> action)+(DbConnection connection) => { } in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerStorage.cs:line 319 at T Hangfire.SqlServer.SqlServerStorage.UseConnection<T>(DbConnection dedicatedConnection, Func<DbConnection, T> func) in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerStorage.cs:line 257 at T Hangfire.SqlServer.SqlServerStorage.UseTransaction<T>(DbConnection dedicatedConnection, Func<DbConnection, DbTransaction, T> func, IsolationLevel? isolationLevel) in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerStorage.cs:line 307 at void Hangfire.SqlServer.SqlServerStorage.UseTransaction(DbConnection dedicatedConnection, Action<DbConnection, DbTransaction> action) in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerStorage.cs:line 270 at void Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit() in C:/projects/hangfire-525/src/Hangfire.SqlServer/SqlServerWriteOnlyTransaction.cs:line 69 at void Hangfire.RecurringJobManager.AddOrUpdate(string recurringJobId, Job job, string cronExpression, RecurringJobOptions options) in C:/projects/hangfire-525/src/Hangfire.Core/RecurringJobManager.cs:line 148 at void Hangfire.RecurringJobManagerExtensions.AddOrUpdate(IRecurringJobManager manager, string recurringJobId, Job job, string cronExpression, TimeZoneInfo timeZone, string queue) in C:/projects/hangfire-525/src/Hangfire.Core/RecurringJobManagerExtensions.cs:line 65 at void Hangfire.RecurringJob.AddOrUpdate(Expression<Func<Task>> methodCall, string cronExpression, TimeZoneInfo timeZone, string queue) in C:/projects/hangfire-525/src/Hangfire.Core/RecurringJob.cs:line 379 at async Task Volo.Abp.BackgroundWorkers.Hangfire.HangfireBackgroundWorkerManager.AddAsync(IBackgroundWorker worker, CancellationToken cancellationToken) at async Task Volo.Abp.Identity.AbpIdentityProDomainModule.OnApplicationInitializationAsync(ApplicationInitializationContext context) at void Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at void Nito.AsyncEx.AsyncContext.Run(Action action)+(Task t) => { } at void Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) at void Nito.AsyncEx.AsyncContext.Run(Func<Task> action) at void Volo.Abp.Threading.AsyncHelper.RunSync(Func<Task> action) at void Volo.Abp.Identity.AbpIdentityProDomainModule.OnApplicationInitialization(ApplicationInitializationContext context) at void Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.Initialize(ApplicationInitializationContext context, IAbpModule module) at void Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Looks like this is a problem of Hangfire, you can check this https://discuss.hangfire.io/t/error-on-hangfire-connections-to-the-sql-server/706/7

  • User Avatar
    0

    Yes, and that's what we do with our own jobs - this job however is part of an internal that we don't control so I can't shorten it.

  • User Avatar
    0

    I would actually think that no matter what, all job ids should fit in the field - something should be applying that, in the adapter for background jobs/workers.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11