hangfire-postgres / Hangfire.PostgreSql

PostgreSql Storage Provider for Hangfire
Other
358 stars 132 forks source link

Changing type of data column in server table #328

Closed brgrz closed 1 year ago

brgrz commented 1 year ago

Lately I observed the data type of the data column in server table changes from jsonb to text and back again resulting in the following exception when the Hangfire server is running. I believe this was introduced with the latest 1.8 versions.

10 state change attempt(s) failed due to an exception, moving job to the FailedState
Npgsql.PostgresException (0x80004005): 42804: column "data" is of type jsonb but expression is of type text

POSITION: 152
   at Npgsql.Internal.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|234_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
   at Npgsql.NpgsqlDataReader.NextResult()
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery(Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteNonQuery()
   at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) in /_/Dapper/SqlMapper.cs:line 2858
   at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in /_/Dapper/SqlMapper.cs:line 581
   at Hangfire.PostgreSql.PostgreSqlWriteOnlyTransaction.<>c__DisplayClass8_0.<SetJobState>b__0(IDbConnection con)
   at Hangfire.PostgreSql.PostgreSqlWriteOnlyTransaction.<Commit>b__4_0(DbConnection connection, DbTransaction _)
   at Hangfire.PostgreSql.PostgreSqlStorage.<>c__DisplayClass25_0.<UseTransaction>b__0(DbConnection connection, DbTransaction transaction)
   at Hangfire.PostgreSql.PostgreSqlStorage.<>c__DisplayClass26_0`1.<UseTransaction>b__0(DbConnection connection)
   at Hangfire.PostgreSql.PostgreSqlStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)
   at Hangfire.PostgreSql.PostgreSqlStorage.UseTransaction(DbConnection dedicatedConnection, Action`2 action, Func`1 transactionScopeFactory)
   at Hangfire.States.BackgroundJobStateChanger.ChangeState(StateChangeContext context)
   at Hangfire.Server.Worker.TryChangeState(BackgroundProcessContext context, IStorageConnection connection, IFetchedJob fetchedJob, IState state, String[] expectedStates, CancellationToken initializeToken, CancellationToken abortToken)
  Exception data:
    Severity: ERROR
    SqlState: 42804
    MessageText: column "data" is of type jsonb but expression is of type text
    Hint: You will need to rewrite or cast the expression.
    Position: 152
    File: parse_target.c
    Line: 587
    Routine: transformAssignedExpr
azygis commented 1 year ago

Ah yes, thank you, experienced this myself recently, but the restart of the application magically worked.

I'll close this one and reopen an older issue, #323.