fix: show shards gives empty expiry time for inf duration shards (#21795)
parent
9a3bd84d61
commit
8fa4d82ce7
|
@ -14,6 +14,7 @@
|
|||
- [#21750](https://github.com/influxdata/influxdb/pull/21750): fix: rename arm rpms with yum-compatible names
|
||||
- [#21777](https://github.com/influxdata/influxdb/pull/21777): fix: convert arm arch names for rpms during builds via docker
|
||||
- [#21792](https://github.com/influxdata/influxdb/pull/21792): fix: error instead of panic for statement rewrite failure
|
||||
- [#21795](https://github.com/influxdata/influxdb/pull/21795): fix: show shards gives empty expiry time for inf duration shards
|
||||
|
||||
v1.9.2 [unreleased]
|
||||
- [#21631](https://github.com/influxdata/influxdb/pull/21631): fix: group by returns multiple results per group in some circumstances
|
||||
|
|
|
@ -810,7 +810,10 @@ func (e *StatementExecutor) executeShowShardsStatement(stmt *influxql.ShowShards
|
|||
for i, owner := range si.Owners {
|
||||
ownerIDs[i] = owner.NodeID
|
||||
}
|
||||
|
||||
expiry := ""
|
||||
if rpi.Duration != 0 {
|
||||
expiry = sgi.EndTime.Add(rpi.Duration).UTC().Format(time.RFC3339)
|
||||
}
|
||||
row.Values = append(row.Values, []interface{}{
|
||||
si.ID,
|
||||
di.Name,
|
||||
|
@ -818,7 +821,7 @@ func (e *StatementExecutor) executeShowShardsStatement(stmt *influxql.ShowShards
|
|||
sgi.ID,
|
||||
sgi.StartTime.UTC().Format(time.RFC3339),
|
||||
sgi.EndTime.UTC().Format(time.RFC3339),
|
||||
sgi.EndTime.Add(rpi.Duration).UTC().Format(time.RFC3339),
|
||||
expiry,
|
||||
joinUint64(ownerIDs),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -820,6 +820,11 @@ func TestServer_Query_DefaultDBAndRP(t *testing.T) {
|
|||
command: `show retention policies ON db0`,
|
||||
exp: `{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["autogen","0s","168h0m0s",1,false],["rp0","0s","168h0m0s",1,true]]}]}]}`,
|
||||
},
|
||||
&Query{
|
||||
name: "show shards works",
|
||||
command: `show shards`,
|
||||
exp: `{"results":[{"statement_id":0,"series":[{"name":"db0","columns":["id","database","retention_policy","shard_group","start_time","end_time","expiry_time","owners"],"values":[[1,"db0","rp0",1,"1999-12-27T00:00:00Z","2000-01-03T00:00:00Z","",""]]}]}]}`,
|
||||
},
|
||||
&Query{
|
||||
name: "default rp",
|
||||
command: `SELECT * FROM db0..cpu GROUP BY *`,
|
||||
|
@ -851,6 +856,42 @@ func TestServer_Query_DefaultDBAndRP(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestServer_ShowShardsNonInf(t *testing.T) {
|
||||
t.Parallel()
|
||||
s := OpenServer(NewConfig())
|
||||
defer s.Close()
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", NewRetentionPolicySpec("rp0", 1, 1000000*time.Hour), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
points := []string{
|
||||
"cpu,host=server01 value=100 1621440001000000000",
|
||||
}
|
||||
if _, err := s.Write("db0", "rp0", strings.Join(points, "\n"), nil); err != nil {
|
||||
t.Fatal("unexpected error: ", err)
|
||||
}
|
||||
|
||||
if err := s.CreateDatabaseAndRetentionPolicy("db0", NewRetentionPolicySpec("rp1", 1, 0), true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.Write("db0", "rp1", strings.Join(points, "\n"), nil); err != nil {
|
||||
t.Fatal("unexpected error: ", err)
|
||||
}
|
||||
|
||||
// inf shard has no expiry_time, shard with expiry has correct expiry_time
|
||||
exp := `{"results":[{"statement_id":0,"series":[{"name":"db0","columns":` +
|
||||
`["id","database","retention_policy","shard_group","start_time","end_time","expiry_time","owners"],"values":[` +
|
||||
`[1,"db0","rp0",1,"2021-05-17T00:00:00Z","2021-05-24T00:00:00Z","2135-06-22T16:00:00Z",""],` +
|
||||
`[2,"db0","rp1",2,"2021-05-17T00:00:00Z","2021-05-24T00:00:00Z","",""]]}]}]}`
|
||||
// Verify the data was written.
|
||||
if res, err := s.Query(`show shards`); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if exp != res {
|
||||
t.Fatalf("unexpected results\nexp: %s\ngot: %s\n", exp, res)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the server can have a database with multiple measurements.
|
||||
func TestServer_Query_Multiple_Measurements(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
|
Loading…
Reference in New Issue