@@ -163,14 +163,6 @@ const (
163
163
`memo: ? ` +
164
164
`}`
165
165
166
- templateReplicationStateType = `{` +
167
- `current_version: ?, ` +
168
- `start_version: ?, ` +
169
- `last_write_version: ?, ` +
170
- `last_write_event_id: ?, ` +
171
- `last_replication_info: ?` +
172
- `}`
173
-
174
166
templateTransferTaskType = `{` +
175
167
`domain_id: ?, ` +
176
168
`workflow_id: ?, ` +
@@ -304,7 +296,6 @@ const (
304
296
templateUpdateCurrentWorkflowExecutionQuery = `UPDATE executions USING TTL 0 ` +
305
297
`SET current_run_id = ?,
306
298
execution = {run_id: ?, create_request_id: ?, state: ?, close_status: ?},
307
- replication_state = {start_version: ?, last_write_version: ?},
308
299
workflow_last_write_version = ?,
309
300
workflow_state = ? ` +
310
301
`WHERE shard_id = ? ` +
@@ -321,16 +312,12 @@ workflow_state = ? ` +
321
312
`and workflow_state = ? `
322
313
323
314
templateCreateCurrentWorkflowExecutionQuery = `INSERT INTO executions (` +
324
- `shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, current_run_id, execution, replication_state, workflow_last_write_version, workflow_state) ` +
325
- `VALUES(?, ?, ?, ?, ?, ?, ?, ?, {run_id: ?, create_request_id: ?, state: ?, close_status: ?}, {start_version: ?, last_write_version: ?}, ?, ?) IF NOT EXISTS USING TTL 0 `
326
-
327
- templateCreateWorkflowExecutionQuery = `INSERT INTO executions (` +
328
- `shard_id, domain_id, workflow_id, run_id, type, execution, next_event_id, visibility_ts, task_id, checksum) ` +
329
- `VALUES(?, ?, ?, ?, ?, ` + templateWorkflowExecutionType + `, ?, ?, ?, ` + templateChecksumType + `) IF NOT EXISTS `
315
+ `shard_id, type, domain_id, workflow_id, run_id, visibility_ts, task_id, current_run_id, execution, workflow_last_write_version, workflow_state) ` +
316
+ `VALUES(?, ?, ?, ?, ?, ?, ?, ?, {run_id: ?, create_request_id: ?, state: ?, close_status: ?}, ?, ?) IF NOT EXISTS USING TTL 0 `
330
317
331
318
templateCreateWorkflowExecutionWithVersionHistoriesQuery = `INSERT INTO executions (` +
332
- `shard_id, domain_id, workflow_id, run_id, type, execution, next_event_id, visibility_ts, task_id, version_histories, version_histories_encoding, checksum) ` +
333
- `VALUES(?, ?, ?, ?, ?, ` + templateWorkflowExecutionType + `, ?, ?, ?, ?, ?, ` + templateChecksumType + `) IF NOT EXISTS `
319
+ `shard_id, domain_id, workflow_id, run_id, type, execution, next_event_id, visibility_ts, task_id, version_histories, version_histories_encoding, checksum, workflow_last_write_version, workflow_state ) ` +
320
+ `VALUES(?, ?, ?, ?, ?, ` + templateWorkflowExecutionType + `, ?, ?, ?, ?, ?, ` + templateChecksumType + `, ?, ? ) IF NOT EXISTS `
334
321
335
322
templateCreateTransferTaskQuery = `INSERT INTO executions (` +
336
323
`shard_id, type, domain_id, workflow_id, run_id, transfer, visibility_ts, task_id) ` +
@@ -355,7 +342,7 @@ workflow_state = ? ` +
355
342
`and task_id = ? ` +
356
343
`IF range_id = ?`
357
344
358
- templateGetWorkflowExecutionQuery = `SELECT execution, replication_state, activity_map, timer_map, ` +
345
+ templateGetWorkflowExecutionQuery = `SELECT execution, activity_map, timer_map, ` +
359
346
`child_executions_map, request_cancel_map, signal_map, signal_requested, buffered_events_list, ` +
360
347
`buffered_replication_tasks_map, version_histories, version_histories_encoding, checksum ` +
361
348
`FROM executions ` +
@@ -367,7 +354,7 @@ workflow_state = ? ` +
367
354
`and visibility_ts = ? ` +
368
355
`and task_id = ?`
369
356
370
- templateGetCurrentExecutionQuery = `SELECT current_run_id, execution, replication_state ` +
357
+ templateGetCurrentExecutionQuery = `SELECT current_run_id, execution, workflow_last_write_version ` +
371
358
`FROM executions ` +
372
359
`WHERE shard_id = ? ` +
373
360
`and type = ? ` +
@@ -886,8 +873,10 @@ func (d *cassandraPersistence) CreateWorkflowExecution(
886
873
if execution , ok := previous ["execution" ].(map [string ]interface {}); ok {
887
874
// CreateWorkflowExecution failed because it already exists
888
875
executionInfo := createWorkflowExecutionInfo (execution )
889
- replicationState := createReplicationState (previous ["replication_state" ].(map [string ]interface {}))
890
- lastWriteVersion := replicationState .LastWriteVersion
876
+ lastWriteVersion := common .EmptyVersion
877
+ if previous ["workflow_last_write_version" ] != nil {
878
+ lastWriteVersion = previous ["workflow_last_write_version" ].(int64 )
879
+ }
891
880
892
881
msg := fmt .Sprintf ("Workflow execution already running. WorkflowId: %v, RunId: %v, rangeID: %v, columns: (%v)" ,
893
882
executionInfo .WorkflowID , executionInfo .RunID , request .RangeID , strings .Join (columns , "," ))
@@ -918,10 +907,9 @@ func (d *cassandraPersistence) CreateWorkflowExecution(
918
907
} else if rowType == rowTypeExecution && runID == executionInfo .RunID {
919
908
msg := fmt .Sprintf ("Workflow execution already running. WorkflowId: %v, RunId: %v, rangeID: %v" ,
920
909
executionInfo .WorkflowID , executionInfo .RunID , request .RangeID )
921
- replicationState := createReplicationState (previous ["replication_state" ].(map [string ]interface {}))
922
- lastWriteVersion = common .EmptyVersion
923
- if replicationState != nil {
924
- lastWriteVersion = replicationState .LastWriteVersion
910
+ lastWriteVersion := common .EmptyVersion
911
+ if previous ["workflow_last_write_version" ] != nil {
912
+ lastWriteVersion = previous ["workflow_last_write_version" ].(int64 )
925
913
}
926
914
return nil , & p.WorkflowExecutionAlreadyStartedError {
927
915
Msg : msg ,
@@ -1111,16 +1099,13 @@ func (d *cassandraPersistence) UpdateWorkflowExecution(
1111
1099
}
1112
1100
1113
1101
} else {
1114
- startVersion := updateWorkflow .StartVersion
1115
1102
lastWriteVersion := updateWorkflow .LastWriteVersion
1116
1103
batch .Query (templateUpdateCurrentWorkflowExecutionQuery ,
1117
1104
runID ,
1118
1105
runID ,
1119
1106
executionInfo .CreateRequestID ,
1120
1107
executionInfo .State ,
1121
1108
executionInfo .CloseStatus ,
1122
- startVersion ,
1123
- lastWriteVersion ,
1124
1109
lastWriteVersion ,
1125
1110
executionInfo .State ,
1126
1111
d .shardID ,
@@ -1216,7 +1201,6 @@ func (d *cassandraPersistence) ResetWorkflowExecution(
1216
1201
newRunID := request .NewWorkflowSnapshot .ExecutionInfo .RunID
1217
1202
newExecutionInfo := request .NewWorkflowSnapshot .ExecutionInfo
1218
1203
1219
- startVersion := request .NewWorkflowSnapshot .StartVersion
1220
1204
lastWriteVersion := request .NewWorkflowSnapshot .LastWriteVersion
1221
1205
1222
1206
batch .Query (templateUpdateCurrentWorkflowExecutionQuery ,
@@ -1225,8 +1209,6 @@ func (d *cassandraPersistence) ResetWorkflowExecution(
1225
1209
newExecutionInfo .CreateRequestID ,
1226
1210
newExecutionInfo .State ,
1227
1211
newExecutionInfo .CloseStatus ,
1228
- startVersion ,
1229
- lastWriteVersion ,
1230
1212
lastWriteVersion ,
1231
1213
newExecutionInfo .State ,
1232
1214
d .shardID ,
@@ -1359,11 +1341,9 @@ func (d *cassandraPersistence) ConflictResolveWorkflowExecution(
1359
1341
1360
1342
case p .ConflictResolveWorkflowModeUpdateCurrent :
1361
1343
executionInfo := resetWorkflow .ExecutionInfo
1362
- startVersion := resetWorkflow .StartVersion
1363
1344
lastWriteVersion := resetWorkflow .LastWriteVersion
1364
1345
if newWorkflow != nil {
1365
1346
executionInfo = newWorkflow .ExecutionInfo
1366
- startVersion = newWorkflow .StartVersion
1367
1347
lastWriteVersion = newWorkflow .LastWriteVersion
1368
1348
}
1369
1349
runID := executionInfo .RunID
@@ -1380,8 +1360,6 @@ func (d *cassandraPersistence) ConflictResolveWorkflowExecution(
1380
1360
createRequestID ,
1381
1361
state ,
1382
1362
closeStatus ,
1383
- startVersion ,
1384
- lastWriteVersion ,
1385
1363
lastWriteVersion ,
1386
1364
state ,
1387
1365
shardID ,
@@ -1403,8 +1381,6 @@ func (d *cassandraPersistence) ConflictResolveWorkflowExecution(
1403
1381
createRequestID ,
1404
1382
state ,
1405
1383
closeStatus ,
1406
- startVersion ,
1407
- lastWriteVersion ,
1408
1384
lastWriteVersion ,
1409
1385
state ,
1410
1386
shardID ,
@@ -1683,10 +1659,9 @@ func (d *cassandraPersistence) GetCurrentExecution(
1683
1659
1684
1660
currentRunID := result ["current_run_id" ].(gocql.UUID ).String ()
1685
1661
executionInfo := createWorkflowExecutionInfo (result ["execution" ].(map [string ]interface {}))
1686
- replicationState := createReplicationState (result ["replication_state" ].(map [string ]interface {}))
1687
1662
lastWriteVersion := common .EmptyVersion
1688
- if replicationState != nil {
1689
- lastWriteVersion = replicationState . LastWriteVersion
1663
+ if result [ "workflow_last_write_version" ] != nil {
1664
+ lastWriteVersion = result [ "workflow_last_write_version" ].( int64 )
1690
1665
}
1691
1666
return & p.GetCurrentExecutionResponse {
1692
1667
RunID : currentRunID ,
@@ -2385,34 +2360,3 @@ func newShardOwnershipLostError(
2385
2360
rangeID , strings .Join (columns , "," )),
2386
2361
}
2387
2362
}
2388
-
2389
- func createReplicationState (
2390
- result map [string ]interface {},
2391
- ) * p.ReplicationState {
2392
-
2393
- if len (result ) == 0 {
2394
- return nil
2395
- }
2396
-
2397
- info := & p.ReplicationState {}
2398
- for k , v := range result {
2399
- switch k {
2400
- case "current_version" :
2401
- info .CurrentVersion = v .(int64 )
2402
- case "start_version" :
2403
- info .StartVersion = v .(int64 )
2404
- case "last_write_version" :
2405
- info .LastWriteVersion = v .(int64 )
2406
- case "last_write_event_id" :
2407
- info .LastWriteEventID = v .(int64 )
2408
- case "last_replication_info" :
2409
- info .LastReplicationInfo = make (map [string ]* p.ReplicationInfo )
2410
- replicationInfoMap := v .(map [string ]map [string ]interface {})
2411
- for key , value := range replicationInfoMap {
2412
- info .LastReplicationInfo [key ] = createReplicationInfo (value )
2413
- }
2414
- }
2415
- }
2416
-
2417
- return info
2418
- }
0 commit comments