Skip to content

Commit

Permalink
fix: fast path for createShardGroup@coordinator
Browse files Browse the repository at this point in the history
Signed-off-by: huang-feiteng <[email protected]>
  • Loading branch information
huang-feiteng committed Jul 26, 2024
1 parent 8c8e855 commit f259320
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions coordinator/record_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func TestRetryWriteRecordErr(t *testing.T) {
_, err = createMeasurement(db, rp, mst, &MockRWMetaClient{MeasurementErr: meta.ErrMeasurementNotFound, CreateMeasurementErr: io.EOF}, &mstInfo, &sameSchema, config.COLUMNSTORE)
assert.Equal(t, err, io.EOF)

rpInfo := NewRetentionPolicy("rp0", time.Hour, config.COLUMNSTORE)
preSg := &rpInfo.ShardGroups[0]
sg, _, _ := createShardGroup(db, rp, &MockRWMetaClient{}, &preSg, time.Now(), 0, config.COLUMNSTORE)
assert.Equal(t, sg, &rpInfo.ShardGroups[0])
Expand Down
2 changes: 1 addition & 1 deletion coordinator/write_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func createMeasurement(database, retentionPolicy, name string, client ComMetaCli
func createShardGroup(database, retentionPolicy string, client ComMetaClient, preSg **meta2.ShardGroupInfo, ts time.Time,
version uint32, engineType config.EngineType) (*meta2.ShardGroupInfo, bool, error) {
// fast path, time is contained
if *preSg != nil && (*preSg).Contains(ts) {
if *preSg != nil && (*preSg).Contains(ts) && (*preSg).EngineType == engineType {
return *preSg, true, nil
}

Expand Down

0 comments on commit f259320

Please sign in to comment.