|
63 | 63 | PostgresSpillFileMissingRe = regexp.MustCompile(`Unable to restore changes for xid \d+`) |
64 | 64 | MySqlRdsBinlogFileNotFoundRe = regexp.MustCompile(`File '/rdsdbdata/log/binlog/mysql-bin-changelog.\d+' not found`) |
65 | 65 | MongoPoolClearedErrorRe = regexp.MustCompile(`connection pool for .+ was cleared because another operation failed with`) |
| 66 | + MongoServerSideTimeoutRe = regexp.MustCompile(`calculated server-side timeout \(.*\) is less than or equal to \d+`) |
66 | 67 | ) |
67 | 68 |
|
68 | 69 | func (e ErrorAction) String() string { |
@@ -221,6 +222,10 @@ var ( |
221 | 222 | ErrorNotifyChangeStreamHistoryLost = ErrorClass{ |
222 | 223 | Class: "NOTIFY_CHANGE_STREAM_HISTORY_LOST", action: NotifyUser, |
223 | 224 | } |
| 225 | + // ErrorNotifyMongoServerSideTimeout fires when the Mongo driver rejects Watch because the computed maxTimeMS is <= 0 |
| 226 | + ErrorNotifyMongoServerSideTimeout = ErrorClass{ |
| 227 | + Class: "NOTIFY_MONGO_INVALID_TIMEOUT", action: NotifyUser, |
| 228 | + } |
224 | 229 | ErrorNotifyPostgresLogicalMessageProcessing = ErrorClass{ |
225 | 230 | Class: "NOTIFY_POSTGRES_LOGICAL_MESSAGE_PROCESSING_ERROR", action: NotifyUser, |
226 | 231 | } |
@@ -1136,6 +1141,19 @@ func GetErrorClass(ctx context.Context, err error) (ErrorClass, ErrorInfo) { |
1136 | 1141 | } |
1137 | 1142 | } |
1138 | 1143 |
|
| 1144 | + if mongoCreateChangeStreamErr, ok := errors.AsType[*exceptions.MongoCreateChangeStreamError](err); ok { |
| 1145 | + if MongoServerSideTimeoutRe.MatchString(mongoCreateChangeStreamErr.Error()) { |
| 1146 | + return ErrorNotifyMongoServerSideTimeout, ErrorInfo{ |
| 1147 | + Source: ErrorSourceMongoDB, |
| 1148 | + Code: "SERVER_SIDE_TIMEOUT", |
| 1149 | + } |
| 1150 | + } |
| 1151 | + return ErrorOther, ErrorInfo{ |
| 1152 | + Source: ErrorSourceMongoDB, |
| 1153 | + Code: "UNKNOWN", |
| 1154 | + } |
| 1155 | + } |
| 1156 | + |
1139 | 1157 | return ErrorOther, ErrorInfo{ |
1140 | 1158 | Source: ErrorSourceOther, |
1141 | 1159 | Code: "UNKNOWN", |
|
0 commit comments