Skip to content

Commit

Permalink
scope to a smaller transaction (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik authored Oct 23, 2023
1 parent 5afd7fe commit b1be612
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions flow/connectors/snowflake/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,14 @@ func (c *SnowflakeConnector) SyncRecords(req *model.SyncRecordsRequest) (*model.
}
syncBatchID = syncBatchID + 1

var res *model.SyncResponse
if req.SyncMode == protos.QRepSyncMode_QREP_SYNC_MODE_STORAGE_AVRO {
res, err = c.syncRecordsViaAvro(req, rawTableIdentifier, syncBatchID)
if err != nil {
return nil, err
}
}

// transaction for SyncRecords
syncRecordsTx, err := c.database.BeginTx(c.ctx, nil)
if err != nil {
Expand All @@ -510,13 +518,7 @@ func (c *SnowflakeConnector) SyncRecords(req *model.SyncRecordsRequest) (*model.
}
}()

var res *model.SyncResponse
if req.SyncMode == protos.QRepSyncMode_QREP_SYNC_MODE_STORAGE_AVRO {
res, err = c.syncRecordsViaAvro(req, rawTableIdentifier, syncBatchID)
if err != nil {
return nil, err
}
} else if req.SyncMode == protos.QRepSyncMode_QREP_SYNC_MODE_MULTI_INSERT {
if req.SyncMode == protos.QRepSyncMode_QREP_SYNC_MODE_MULTI_INSERT {
res, err = c.syncRecordsViaSQL(req, rawTableIdentifier, syncBatchID, syncRecordsTx)
if err != nil {
return nil, err
Expand All @@ -539,7 +541,6 @@ func (c *SnowflakeConnector) SyncRecords(req *model.SyncRecordsRequest) (*model.

func (c *SnowflakeConnector) syncRecordsViaSQL(req *model.SyncRecordsRequest, rawTableIdentifier string,
syncBatchID int64, syncRecordsTx *sql.Tx) (*model.SyncResponse, error) {

records := make([]snowflakeRawRecord, 0)
tableNameRowsMapping := make(map[string]uint32)

Expand Down

0 comments on commit b1be612

Please sign in to comment.