@@ -595,6 +595,11 @@ func (d *cassandraPersistence) CreateShard(request *CreateShardRequest) error {
595
595
previous := make (map [string ]interface {})
596
596
applied , err := query .MapScanCAS (previous )
597
597
if err != nil {
598
+ if isThrottlingError (err ) {
599
+ return & workflow.ServiceBusyError {
600
+ Message : fmt .Sprintf ("CreateShard operation failed. Error: %v" , err ),
601
+ }
602
+ }
598
603
return & workflow.InternalServiceError {
599
604
Message : fmt .Sprintf ("CreateShard operation failed. Error : %v" , err ),
600
605
}
@@ -628,6 +633,10 @@ func (d *cassandraPersistence) GetShard(request *GetShardRequest) (*GetShardResp
628
633
return nil , & workflow.EntityNotExistsError {
629
634
Message : fmt .Sprintf ("Shard not found. ShardId: %v" , shardID ),
630
635
}
636
+ } else if isThrottlingError (err ) {
637
+ return nil , & workflow.ServiceBusyError {
638
+ Message : fmt .Sprintf ("GetShard operation failed. Error: %v" , err ),
639
+ }
631
640
}
632
641
633
642
return nil , & workflow.InternalServiceError {
@@ -665,6 +674,11 @@ func (d *cassandraPersistence) UpdateShard(request *UpdateShardRequest) error {
665
674
previous := make (map [string ]interface {})
666
675
applied , err := query .MapScanCAS (previous )
667
676
if err != nil {
677
+ if isThrottlingError (err ) {
678
+ return & workflow.ServiceBusyError {
679
+ Message : fmt .Sprintf ("UpdateShard operation failed. Error: %v" , err ),
680
+ }
681
+ }
668
682
return & workflow.InternalServiceError {
669
683
Message : fmt .Sprintf ("UpdateShard operation failed. Error: %v" , err ),
670
684
}
@@ -724,6 +738,10 @@ func (d *cassandraPersistence) CreateWorkflowExecution(request *CreateWorkflowEx
724
738
// Write may have succeeded, but we don't know
725
739
// return this info to the caller so they have the option of trying to find out by executing a read
726
740
return nil , & TimeoutError {Msg : fmt .Sprintf ("CreateWorkflowExecution timed out. Error: %v" , err )}
741
+ } else if isThrottlingError (err ) {
742
+ return nil , & workflow.ServiceBusyError {
743
+ Message : fmt .Sprintf ("CreateWorkflowExecution operation failed. Error: %v" , err ),
744
+ }
727
745
}
728
746
return nil , & workflow.InternalServiceError {
729
747
Message : fmt .Sprintf ("CreateWorkflowExecution operation failed. Error: %v" , err ),
@@ -887,6 +905,10 @@ func (d *cassandraPersistence) GetWorkflowExecution(request *GetWorkflowExecutio
887
905
Message : fmt .Sprintf ("Workflow execution not found. WorkflowId: %v, RunId: %v" ,
888
906
execution .GetWorkflowId (), execution .GetRunId ()),
889
907
}
908
+ } else if isThrottlingError (err ) {
909
+ return nil , & workflow.ServiceBusyError {
910
+ Message : fmt .Sprintf ("GetWorkflowExecution operation failed. Error: %v" , err ),
911
+ }
890
912
}
891
913
892
914
return nil , & workflow.InternalServiceError {
@@ -1035,6 +1057,10 @@ func (d *cassandraPersistence) UpdateWorkflowExecution(request *UpdateWorkflowEx
1035
1057
// Write may have succeeded, but we don't know
1036
1058
// return this info to the caller so they have the option of trying to find out by executing a read
1037
1059
return & TimeoutError {Msg : fmt .Sprintf ("UpdateWorkflowExecution timed out. Error: %v" , err )}
1060
+ } else if isThrottlingError (err ) {
1061
+ return & workflow.ServiceBusyError {
1062
+ Message : fmt .Sprintf ("UpdateWorkflowExecution operation failed. Error: %v" , err ),
1063
+ }
1038
1064
}
1039
1065
return & workflow.InternalServiceError {
1040
1066
Message : fmt .Sprintf ("UpdateWorkflowExecution operation failed. Error: %v" , err ),
@@ -1109,6 +1135,11 @@ func (d *cassandraPersistence) DeleteWorkflowExecution(request *DeleteWorkflowEx
1109
1135
1110
1136
err := query .Exec ()
1111
1137
if err != nil {
1138
+ if isThrottlingError (err ) {
1139
+ return & workflow.ServiceBusyError {
1140
+ Message : fmt .Sprintf ("DeleteWorkflowExecution operation failed. Error: %v" , err ),
1141
+ }
1142
+ }
1112
1143
return & workflow.InternalServiceError {
1113
1144
Message : fmt .Sprintf ("DeleteWorkflowExecution operation failed. Error: %v" , err ),
1114
1145
}
@@ -1135,6 +1166,10 @@ func (d *cassandraPersistence) GetCurrentExecution(request *GetCurrentExecutionR
1135
1166
Message : fmt .Sprintf ("Workflow execution not found. WorkflowId: %v" ,
1136
1167
request .WorkflowID ),
1137
1168
}
1169
+ } else if isThrottlingError (err ) {
1170
+ return nil , & workflow.ServiceBusyError {
1171
+ Message : fmt .Sprintf ("GetCurrentExecution operation failed. Error: %v" , err ),
1172
+ }
1138
1173
}
1139
1174
1140
1175
return nil , & workflow.InternalServiceError {
@@ -1197,6 +1232,11 @@ func (d *cassandraPersistence) CompleteTransferTask(request *CompleteTransferTas
1197
1232
1198
1233
err := query .Exec ()
1199
1234
if err != nil {
1235
+ if isThrottlingError (err ) {
1236
+ return & workflow.ServiceBusyError {
1237
+ Message : fmt .Sprintf ("CompleteTransferTask operation failed. Error: %v" , err ),
1238
+ }
1239
+ }
1200
1240
return & workflow.InternalServiceError {
1201
1241
Message : fmt .Sprintf ("CompleteTransferTask operation failed. Error: %v" , err ),
1202
1242
}
@@ -1218,6 +1258,11 @@ func (d *cassandraPersistence) CompleteTimerTask(request *CompleteTimerTaskReque
1218
1258
1219
1259
err := query .Exec ()
1220
1260
if err != nil {
1261
+ if isThrottlingError (err ) {
1262
+ return & workflow.ServiceBusyError {
1263
+ Message : fmt .Sprintf ("CompleteTimerTask operation failed. Error: %v" , err ),
1264
+ }
1265
+ }
1221
1266
return & workflow.InternalServiceError {
1222
1267
Message : fmt .Sprintf ("CompleteTimerTask operation failed. Error: %v" , err ),
1223
1268
}
@@ -1256,9 +1301,14 @@ func (d *cassandraPersistence) LeaseTaskList(request *LeaseTaskListRequest) (*Le
1256
1301
request .TaskList ,
1257
1302
request .TaskType ,
1258
1303
0 )
1304
+ } else if isThrottlingError (err ) {
1305
+ return nil , & workflow.ServiceBusyError {
1306
+ Message : fmt .Sprintf ("LeaseTaskList operation failed. TaskList: %v, TaskType: %v, Error: %v" ,
1307
+ request .TaskList , request .TaskType , err ),
1308
+ }
1259
1309
} else {
1260
1310
return nil , & workflow.InternalServiceError {
1261
- Message : fmt .Sprintf ("LeaseTaskList operation failed. TaskList: %v, TaskType: %v, Error : %v" ,
1311
+ Message : fmt .Sprintf ("LeaseTaskList operation failed. TaskList: %v, TaskType: %v, Error: %v" ,
1262
1312
request .TaskList , request .TaskType , err ),
1263
1313
}
1264
1314
}
@@ -1281,6 +1331,11 @@ func (d *cassandraPersistence) LeaseTaskList(request *LeaseTaskListRequest) (*Le
1281
1331
previous := make (map [string ]interface {})
1282
1332
applied , err := query .MapScanCAS (previous )
1283
1333
if err != nil {
1334
+ if isThrottlingError (err ) {
1335
+ return nil , & workflow.ServiceBusyError {
1336
+ Message : fmt .Sprintf ("LeaseTaskList operation failed. Error: %v" , err ),
1337
+ }
1338
+ }
1284
1339
return nil , & workflow.InternalServiceError {
1285
1340
Message : fmt .Sprintf ("LeaseTaskList operation failed. Error : %v" , err ),
1286
1341
}
@@ -1316,6 +1371,11 @@ func (d *cassandraPersistence) UpdateTaskList(request *UpdateTaskListRequest) (*
1316
1371
previous := make (map [string ]interface {})
1317
1372
applied , err := query .MapScanCAS (previous )
1318
1373
if err != nil {
1374
+ if isThrottlingError (err ) {
1375
+ return nil , & workflow.ServiceBusyError {
1376
+ Message : fmt .Sprintf ("UpdateTaskList operation failed. Error: %v" , err ),
1377
+ }
1378
+ }
1319
1379
return nil , & workflow.InternalServiceError {
1320
1380
Message : fmt .Sprintf ("UpdateTaskList operation failed. Error: %v" , err ),
1321
1381
}
@@ -1390,8 +1450,13 @@ func (d *cassandraPersistence) CreateTasks(request *CreateTasksRequest) (*Create
1390
1450
previous := make (map [string ]interface {})
1391
1451
applied , _ , err := d .session .MapExecuteBatchCAS (batch , previous )
1392
1452
if err != nil {
1453
+ if isThrottlingError (err ) {
1454
+ return nil , & workflow.ServiceBusyError {
1455
+ Message : fmt .Sprintf ("CreateTasks operation failed. Error: %v" , err ),
1456
+ }
1457
+ }
1393
1458
return nil , & workflow.InternalServiceError {
1394
- Message : fmt .Sprintf ("CreateTask operation failed. Error : %v" , err ),
1459
+ Message : fmt .Sprintf ("CreateTasks operation failed. Error : %v" , err ),
1395
1460
}
1396
1461
}
1397
1462
if ! applied {
@@ -1466,6 +1531,11 @@ func (d *cassandraPersistence) CompleteTask(request *CompleteTaskRequest) error
1466
1531
1467
1532
err := query .Exec ()
1468
1533
if err != nil {
1534
+ if isThrottlingError (err ) {
1535
+ return & workflow.ServiceBusyError {
1536
+ Message : fmt .Sprintf ("CompleteTask operation failed. Error: %v" , err ),
1537
+ }
1538
+ }
1469
1539
return & workflow.InternalServiceError {
1470
1540
Message : fmt .Sprintf ("CompleteTask operation failed. Error: %v" , err ),
1471
1541
}
@@ -1507,6 +1577,11 @@ func (d *cassandraPersistence) GetTimerIndexTasks(request *GetTimerIndexTasksReq
1507
1577
}
1508
1578
1509
1579
if err := iter .Close (); err != nil {
1580
+ if isThrottlingError (err ) {
1581
+ return nil , & workflow.ServiceBusyError {
1582
+ Message : fmt .Sprintf ("GetTimerTasks operation failed. Error: %v" , err ),
1583
+ }
1584
+ }
1510
1585
return nil , & workflow.InternalServiceError {
1511
1586
Message : fmt .Sprintf ("GetTimerTasks operation failed. Error: %v" , err ),
1512
1587
}
@@ -2035,6 +2110,14 @@ func isTimeoutError(err error) bool {
2035
2110
return ok
2036
2111
}
2037
2112
2113
+ func isThrottlingError (err error ) bool {
2114
+ if req , ok := err .(gocql.RequestError ); ok {
2115
+ // gocql does not expose the constant errOverloaded = 0x1001
2116
+ return req .Code () == 0x1001
2117
+ }
2118
+ return false
2119
+ }
2120
+
2038
2121
// GetVisibilityTSFrom - helper method to get visibility timestamp
2039
2122
func GetVisibilityTSFrom (task Task ) time.Time {
2040
2123
switch task .GetType () {
0 commit comments