Skip to content

Commit cd6bdef

Browse files
authored
Improve sql query of delete expired data query for mysql
* fix mysql8 lock waits #1673 * Compatible with lower versions of MySql
1 parent c0bddf1 commit cd6bdef

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/DotNetCore.CAP.MySql/IDataStorage.MySql.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ SELECT Id
217217
FROM `{table}`
218218
WHERE ExpiresAt < @timeout
219219
AND StatusName IN ('{StatusName.Succeeded}', '{StatusName.Failed}')
220+
ORDER BY Id
220221
LIMIT @batchCount
222+
{ (SupportSkipLocked ? "FOR UPDATE SKIP LOCKED" : "FOR UPDATE")}
221223
) AS T ON P.Id = T.Id;",
222224
null,
223225
new MySqlParameter("@timeout", timeout),

0 commit comments

Comments
 (0)