Closed mitchellvanbijleveld closed 10 months ago
More or less the same here.
Just updated my unified self-host container and this is what I get in the logs:
Any help will be apreciated.
Thank you...
gitHash cf4d8a4 is working, ea162d5 is not
That commit modifies GrantRepository, and logs say something about 'grant' table
Working older version (11 days ago): docker image pull bitwarden/self-host@sha256:495424ccf31ca2ce0dca4b96774531efbc49ab595600d004694a78a31170bc2c
Hi there,
Thank you for your report!
I was able to reproduce this issue, and I have flagged this to our engineering team.
If you wish to add any further information/screenshots/recordings etc., please feel free to do so at any time - our engineering team will be happy to review these.
Thanks once again!
As I've just upgraded my Bitwarden install from 2023.12.0 to 2024.1.0, I too ran into this issue. However, I've done some digging around and added some findings to this issue: https://github.com/bitwarden/server/issues/3651#issuecomment-1885849819
To summarize, what I could see was that ALTER TABLE
GrantADD CONSTRAINT
PK_GrantPRIMARY KEY (
Id);
is actually the migration that's failing due to the existing data. The error Can't DROP INDEX
PRIMARY; check that it exists
is a side-effect because of the system attempting to re-run migrations that have already altered the database.
I do like to point out though that I am running MySQL 8.0.35 and the platform is ARM64, so this issue does not appear to be specific to MariaDB nor AMD64.
I did find a way to somewhat work around the issue which involved some manual queries but I managed to get the Bitwarden instance running again
mysql -u root -p bitwarden_vault
Grant
table: show create table `Grant`;
. There should not be a PRIMARY KEY
and there should be an Id
column.Id
with alter table `Grant` drop column Id;
alter table `Grant` add constraint PK_Grant_Id PRIMARY KEY (`Key`);
(Note: I made the assumption that Key
was the original PK, not 100% sure but it's just to make the migration dropping the PK not fail)mysql
mysqldump --no-create-info --complete-insert -u root -p bitwarden_vault Grant > grant.sql
. Make sure to not lose this file, you'll need it later on!mysql -u root -p bitwarden_vault
TRUNCATE `Grant`;
(DESTRUCTIVE)docker compose exec bitwarden tail -f /var/log/bitwarden/admin.log
Application started. Press Ctrl+C to shut down.
shortly after.mysql -u root -p bitwarden_vault < grant.sql
@mitchellvanbijleveld can you pull the latest from main
and give this a try? We made a modification to the database migration.
@withinfocus I am sorry to have you ask, but pulling from main
? I might be confused but the Docker self-host image is only available as dev/beta, right? I tried the dev which was updated like 15 minutes ago but that one isn't working.
The docker compose logs
shows a lot of MariaDB related connection errors:
bitwarden-db-1 | 2024-01-11 21:33:58 126 [Warning] Aborted connection 126 to db: 'unconnected' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:34:23 132 [Warning] Aborted connection 132 to db: 'BWUSER' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:34:23 130 [Warning] Aborted connection 130 to db: 'unconnected' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:34:47 136 [Warning] Aborted connection 136 to db: 'BWUSER' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:34:47 134 [Warning] Aborted connection 134 to db: 'unconnected' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:35:12 139 [Warning] Aborted connection 139 to db: 'BWUSER' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
bitwarden-db-1 | 2024-01-11 21:35:12 138 [Warning] Aborted connection 138 to db: 'unconnected' user: 'BWUSER' host: '172.21.0.3' (Got an error reading communication packets)
@withinfocus the admin logs show the following:
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (4ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
CALL POMELO_BEFORE_DROP_PRIMARY_KEY(NULL, 'Grant');
ALTER TABLE `Grant` DROP PRIMARY KEY;
Unhandled exception. MySqlConnector.MySqlException (0x80004005): Can't DROP INDEX `PRIMARY`; check that it exists
at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in /_/src/MySqlConnector/Core/ResultSet.cs:line 43
at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 130
at MySqlConnector.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 468
at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, Activity activity, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/CommandExecutor.cs:line 56
at MySqlConnector.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlCommand.cs:line 296
at MySqlConnector.MySqlCommand.ExecuteNonQuery() in /_/src/MySqlConnector/MySqlCommand.cs:line 107
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
at Bit.MySqlMigrations.MySqlDbMigrator.MigrateDatabase(Boolean enableLogging, CancellationToken cancellationToken) in /source/util/MySqlMigrations/MySqlDbMigrator.cs:line 30
at Bit.Admin.HostedServices.DatabaseMigrationHostedService.StartAsync(CancellationToken cancellationToken) in /source/src/Admin/HostedServices/DatabaseMigrationHostedService.cs:line 29
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Bit.Admin.Program.Main(String[] args) in /source/src/Admin/Program.cs:line 9
And here is another example of docker compose logs
:
bitwarden-bitwarden-1 | 2024-01-11 21:41:54,225 INFO spawned: 'admin' with pid 486
bitwarden-bitwarden-1 | 2024-01-11 21:42:09,244 INFO success: admin entered RUNNING state, process has stayed up for > than 15 seconds (startsecs)
bitwarden-bitwarden-1 | 2024-01-11 21:42:17,969 INFO exited: admin (terminated by SIGABRT (core dumped); not expected)
bitwarden-bitwarden-1 | 2024-01-11 21:42:18,972 INFO spawned: 'admin' with pid 507
bitwarden-bitwarden-1 | 2024-01-11 21:42:33,990 INFO success: admin entered RUNNING state, process has stayed up for > than 15 seconds (startsecs)
bitwarden-bitwarden-1 | 2024-01-11 21:42:42,636 INFO exited: admin (terminated by SIGABRT (core dumped); not expected)
bitwarden-bitwarden-1 | 2024-01-11 21:42:43,638 INFO spawned: 'admin' with pid 527
bitwarden-bitwarden-1 | 2024-01-11 21:42:58,657 INFO success: admin entered RUNNING state, process has stayed up for > than 15 seconds (startsecs)
bitwarden-bitwarden-1 | 2024-01-11 21:43:07,314 INFO exited: admin (terminated by SIGABRT (core dumped); not expected)
bitwarden-bitwarden-1 | 2024-01-11 21:43:08,316 INFO spawned: 'admin' with pid 550
You don't seem to have the latest is all -- I was referring to code merges in this repo, specifically commit db4d7aa60932d867b5c18a42ac3ca567a68dca32
.
Having the same issue with self-host:beta and self-host:2024.1.0-beta, so tried pulling the self-host:dev that have been updated 11 hours ago and the issue is still there.
for now i reverted back to running self-host:2023.12.0-beta
admin.log:
Failed executing DbCommand (3ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
INSERT INTO "ef_temp_Grant" ("Id", "ClientId", "ConsumedDate", "CreationDate", "Data", "Description", "ExpirationDate", "Key", "SessionId", "SubjectId", "Type")
SELECT "Id", IFNULL("ClientId", ''), "ConsumedDate", "CreationDate", IFNULL("Data", ''), "Description", "ExpirationDate", "Key", "SessionId", "SubjectId", IFNULL("Type", '')
FROM "Grant";
Unhandled exception. Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: ef_temp_Grant.Id'.
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.ExecuteReader()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.MigrationCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
at Bit.SqliteMigrations.SqliteDbMigrator.MigrateDatabase(Boolean enableLogging, CancellationToken cancellationToken) in /source/util/SqliteMigrations/SqliteDbMigrator.cs:line 30
at Bit.Admin.HostedServices.DatabaseMigrationHostedService.StartAsync(CancellationToken cancellationToken) in /source/src/Admin/HostedServices/DatabaseMigrationHostedService.cs:line 29
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Bit.Admin.Program.Main(String[] args) in /source/src/Admin/Program.cs:line 9
for now i reverted back to running self-host:2023.12.0-beta
Yes, this is the same one I'm using too until testing each new version with positive results...
This seems to be fixed with commit "PM-5519](https://bitwarden.atlassian.net/browse/PM-5519?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ) PM-5526 PM-5624 PM-5600 More Grant SQL fixes"
Yes, it's working again!!!
I'm running self-host:beta again, version number says 2024.1.2
I'm running self-host:beta
too, but my version number says 2024.1.1
...
Great! Let me check this afternoon :).
self-host:beta 2024.1.2 dca8d00f-dirty still gives me the same error
You wouldn't get the same error as the MySQL migration changed. It now runs what you can see at https://github.com/bitwarden/server/blob/main/util/MySqlMigrations/Migrations/20231214162533_GrantIdWithIndexes.cs#L75-L90 that will delete and re-add the new Id
column. You won't see those same Pomelo errors that caused the initial issue.
Steps To Reproduce
Upgrading the Bitwarden installation from the December beta release to the beta release of the 2nd of January, 2024.
Expected Result
The browser shows Bitwarden's admin page to put in an email address to get a login link.
Actual Result
The browser shows: 502 Bad Gateway nginx
Screenshots or Videos
No response
Additional Context
nginx shows errors, something like
Also, data/bitwarden/logs/admin.log shows:
Githash Version
919d759f-dirty
Environment Details
Running Debian 12, AMD64. This is nginx's config file:
Database Image
docker-compose.yml:
Issue-Link
https://github.com/bitwarden/server/issues/2480
Issue Tracking Info