近期观察日志发现每次服务重启都会出现如下Cap 错误日志。
环境
.Net Core 3.1
DotNetCore.CAP, Version=3.0.3.0
DotNetCore.CAP.MySql, Version=3.0.3.0
[05:54:21 INF] Starting the processing server. at DotNetCore.CAP.Internal.Bootstrapper.BootstrapAsync(CancellationToken stoppingToken) at DotNetCore.CAP.MySql.MySqlStorageInitializer.InitializeAsync(CancellationToken cancellationToken) at DotNetCore.CAP.MySql.MySqlStorageInitializer.InitializeAsync(CancellationToken cancellationToken) at Dapper.SqlMapper.ExecuteImplAsync(IDbConnection cnn, CommandDefinition command, Object param) in C:projectsdapperDapperSqlMapper.Async.cs:line 678 at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:projectsmysqlconnectorsrcMySqlConnectorMySql.Data.MySqlClientMySqlCommand.cs:line 226 at MySqlConnector.Core.CommandExecutor.ExecuteReaderAsync(IReadOnlyList`1 commands, ICommandPayloadCreator payloadCreator, CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken)
in C:projectsmysqlconnectorsrcMySqlConnectorCoreCommandExecutor.cs:line 62 at MySql.Data.MySqlClient.MySqlDataReader.CreateAsync(CommandListPosition commandListPosition, ICommandPayloadCreator payloadCreator, IDictionary`2 cachedProcedures, IMySqlCommand command,
CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) in
C:projectsmysqlconnectorsrcMySqlConnectorMySql.Data.MySqlClientMySqlDataReader.cs:line 391 at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet() in C:projectsmysqlconnectorsrcMySqlConnectorMySql.Data.MySqlClientMySqlDataReader.cs:line 130 at MySqlConnector.Core.ResultSet.ReadResultSetHeaderAsync(IOBehavior ioBehavior) in C:projectsmysqlconnectorsrcMySqlConnectorCoreResultSet.cs:line 49 ---> MySql.Data.MySqlClient.MySqlException (0x80004005): CREATE command denied to user 'connection string' for table 'XXX_TableName'
通过下载源码分析(https://github.com/dotnetcore/CAP), 发现AddCap内部添加了 HostedService
HostedService 内部调用了Create Table 的Sql执行
处理方法:
将此函数重写下,就处理了