-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Startup should fail if DB version is greater than expected #615
Comments
It looks like you might be using an older smtp4dev version (< 3.1.2-ci20200925100) with a DB file which has been already upgraded by a later version (>= 3.1.2-ci20200925100). The ImapUid field was introduced in a recent version but your stack trace doesn't show it being set, which implies this combination.
You can double check what version is running here by looking at the console output on startup.
If I'm right:
- You can upgrade to a version >= 3.1.2-ci20200925100 and this error should go away. You won't lose the messages etc that are already in the DB.
or
- If you want to use the version you've already got running and you're happy to start afresh, you can simply stop smtp4dev and delete the .db file (path printed during startup) before starting again. You'll then get a new DB file with the schema correctly matching the binary you are using.
Please can you confirm if my guess is right here. If correct I'll consider implementing a 'DB version mismatch' error so that people can't accidentally get into this situation.
…------ Original Message ------
From: "AFract" <notifications@github.com<mailto:notifications@github.com>>
To: "rnwood/smtp4dev" <smtp4dev@noreply.github.com<mailto:smtp4dev@noreply.github.com>>
Cc: "Subscribed" <subscribed@noreply.github.com<mailto:subscribed@noreply.github.com>>
Sent: 02/02/2021 15:01:04
Subject: [rnwood/smtp4dev] Error while writing mail to DB (#615)
I have the following SQLite error with the last version when a mail is received :
Message received. Client address 127.0.0.1. From xx To xx.
Processing received message
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (4ms) [Parameters=[@p0<https://github.com/p0>='?', @p1<https://github.com/p1>='?', @p2<https://github.com/p2>='?' (Size = 238353), @p3<https://github.com/p3>='?' (Size = 20), @P4<https://github.com/P4>='?', @p5<https://github.com/p5>='?', @p6<https://github.com/p6>='?', @P7<https://github.com/P7>='?', @p8<https://github.com/p8>='?', @p9<https://github.com/p9>='?' (Size = 92), @p10<https://github.com/p10>='?' (Size = 20)], CommandType='Text', CommandTimeout='30']
INSERT INTO "Messages" ("Id", "AttachmentCount", "Data", "From", "IsUnread", "MimeParseError", "ReceivedDate", "RelayError", "SessionId", "Subject", "To")
VALUES (@p0<https://github.com/p0>, @p1<https://github.com/p1>, @p2<https://github.com/p2>, @p3<https://github.com/p3>, @P4<https://github.com/P4>, @p5<https://github.com/p5>, @p6<https://github.com/p6>, @P7<https://github.com/P7>, @p8<https://github.com/p8>, @p9<https://github.com/p9>, @p10<https://github.com/p10>);
fail: Microsoft.EntityFrameworkCore.Update[10000]
An exception occurred in the database while saving changes for context type 'Rnwood.Smtp4dev.DbModel.Smtp4devDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'NOT NULL constraint failed: Messages.ImapUid'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'NOT NULL constraint failed: Messages.ImapUid'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'NOT NULL constraint failed: Messages.ImapUid'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges()
at Rnwood.Smtp4dev.Server.Smtp4devServer.<>c__DisplayClass14_0.b__0() in /home/vsts/work/1/s/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 308
at Rnwood.Smtp4dev.Server.Smtp4devServer.<>c__DisplayClass11_0.b__0() in /home/vsts/work/1/s/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 234
Session completed. Client address 127.0.0.1. Number of messages 1.
Thank you
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#615>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAKEGF5RTUZWABPAGI7ZR33S5AHTBANCNFSM4W6Y3SEA>.
|
Thank you !
|
rnwood
changed the title
Error while writing mail to DB
Startup should fail if DB version is greater than expected
Feb 3, 2021
Keeping this ticket open to implement the DB version check on startup. If version is greater than expected then startup will fail with an appropriate error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following SQLite error with the last version when a mail is received :
Thank you
The text was updated successfully, but these errors were encountered: