-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-create shard groups #1897
Pre-create shard groups #1897
Changes from 1 commit
67f03ef
b6e7210
7495e6e
c150a8c
686d6b9
35bcd48
0d634c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,9 @@ const ( | |
|
||
// DefaultJoinURLs represents the default URLs for joining a cluster. | ||
DefaultJoinURLs = "" | ||
|
||
// DefaultShardGroupPreCreatePeriod | ||
DefaultShardGroupPreCreatePeriod = 45 * time.Minute | ||
) | ||
|
||
// Config represents the configuration format for the influxd binary. | ||
|
@@ -85,11 +88,12 @@ type Config struct { | |
} `toml:"broker"` | ||
|
||
Data struct { | ||
Dir string `toml:"dir"` | ||
Port int `toml:"port"` | ||
RetentionAutoCreate bool `toml:"retention-auto-create"` | ||
RetentionCheckEnabled bool `toml:"retention-check-enabled"` | ||
RetentionCheckPeriod Duration `toml:"retention-check-period"` | ||
Dir string `toml:"dir"` | ||
Port int `toml:"port"` | ||
RetentionAutoCreate bool `toml:"retention-auto-create"` | ||
RetentionCheckEnabled bool `toml:"retention-check-enabled"` | ||
RetentionCheckPeriod Duration `toml:"retention-check-period"` | ||
ShardGroupPreCreateCheckPeriod Duration `toml:"shard-group-pre-create-check-period"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a pretty awkwardly-named config variable. :-) How about something as simple as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Shard groups" is an implementation detail, one of the reasons I don't like seeing it in the key names. |
||
} `toml:"data"` | ||
|
||
Cluster struct { | ||
|
@@ -148,6 +152,7 @@ func NewConfig() *Config { | |
c.Data.RetentionAutoCreate = true | ||
c.Data.RetentionCheckEnabled = true | ||
c.Data.RetentionCheckPeriod = Duration(10 * time.Minute) | ||
c.Data.ShardGroupPreCreateCheckPeriod = Duration(DefaultShardGroupPreCreatePeriod) | ||
c.Admin.Enabled = true | ||
c.Admin.Port = 8083 | ||
c.ContinuousQuery.RecomputePreviousN = 2 | ||
|
@@ -229,6 +234,15 @@ func (c *Config) JoinURLs() string { | |
} | ||
} | ||
|
||
// ShardGroupPreCreateCheckPeriod returns the check interval to pre-create shard groups. | ||
// If it was not defined in the config, it defaults to DefaultShardGroupPreCreatePeriod | ||
func (c *Config) ShardGroupPreCreateCheckPeriod() time.Duration { | ||
if c.Data.ShardGroupPreCreateCheckPeriod != 0 { | ||
return time.Duration(c.Data.ShardGroupPreCreateCheckPeriod) | ||
} | ||
return DefaultShardGroupPreCreatePeriod | ||
} | ||
|
||
// Size represents a TOML parseable file size. | ||
// Users can specify size using "m" for megabytes and "g" for gigabytes. | ||
type Size int | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,9 @@ const ( | |
deleteUserMessageType = messaging.MessageType(0x32) | ||
|
||
// Shard messages | ||
createShardGroupIfNotExistsMessageType = messaging.MessageType(0x40) | ||
deleteShardGroupMessageType = messaging.MessageType(0x41) | ||
createShardGroupIfNotExistsMessageType = messaging.MessageType(0x40) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we pre-create shards, why do we still have the "explicit create shards" message? In case pre-creation had failed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pre-create happens after then initial create. I'm not real happy with the naming. One represents more of the "initial" creation now, and the other represents "ongoing" creation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, I see. Is there some way to collapse both of these operations into 1 operation? Why are they different? Why not move to a design such that when a retention policy is first created, create the initial shard groups then, and wait for that to complete. And from then one, background creation happens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They take different signatures. The first shard creation happens the first time you write data. Until that point in time, we don't know what to create. After that, we pre-create based on existing shards. So we have to have some pre-processing to determine time buckets for each one, then once that is known, it shares the same code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, OK, let me re-review. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see what you're saying about timestamps. But if the code computed the timestamp for the "precreate" message before it sent it out on the cluster -- it can, since it knows the shard -- and send the timestamp along, then the mesage signatures would be identical and you wouldn't need two messages. Basically, I'm trying to get this implementation as simple as possible, without losing functionality. A "create shard group" message could be just that -- create these shards with these timestamps. Why the message is on the cluster, well, it wouldn't care. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, you should note that since we have a policy regarding shard group duration, you know both the start-time and end-time of a shard group. We can have a single "create shard" message, which has database, retention policy, group ID (which is basically the group ID of the group before the one being created). In fact the message doesn't even need the group ID, the message should just be "create this group of shards with this start-time, this end-time, for this database, and this retention policy". |
||
deleteShardGroupMessageType = messaging.MessageType(0x41) | ||
preCreateShardGroupIfNotExistsMessageType = messaging.MessageType(0x42) | ||
|
||
// Series messages | ||
dropSeriesMessageType = messaging.MessageType(0x50) | ||
|
@@ -69,11 +70,19 @@ type createShardGroupIfNotExistsCommand struct { | |
Policy string `json:"policy"` | ||
Timestamp time.Time `json:"timestamp"` | ||
} | ||
|
||
type deleteShardGroupCommand struct { | ||
Database string `json:"database"` | ||
Policy string `json:"policy"` | ||
ID uint64 `json:"id"` | ||
} | ||
|
||
type preCreateShardGroupIfNotExistsCommand struct { | ||
Database string `json:"database"` | ||
Policy string `json:"policy"` | ||
ID uint64 `json:"id"` | ||
} | ||
|
||
type createUserCommand struct { | ||
Username string `json:"username"` | ||
Password string `json:"password"` | ||
|
@@ -94,11 +103,12 @@ type setPrivilegeCommand struct { | |
Database string `json:"database"` | ||
} | ||
type createRetentionPolicyCommand struct { | ||
Database string `json:"database"` | ||
Name string `json:"name"` | ||
Duration time.Duration `json:"duration"` | ||
ReplicaN uint32 `json:"replicaN"` | ||
SplitN uint32 `json:"splitN"` | ||
Database string `json:"database"` | ||
Name string `json:"name"` | ||
Duration time.Duration `json:"duration"` | ||
ShardGroupDuration time.Duration `json:"shardGroupDuration"` | ||
ReplicaN uint32 `json:"replicaN"` | ||
SplitN uint32 `json:"splitN"` | ||
} | ||
type updateRetentionPolicyCommand struct { | ||
Database string `json:"database"` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1016,6 +1016,9 @@ type RetentionPolicy struct { | |
// Length of time to keep data around. A zero duration means keep the data forever. | ||
Duration time.Duration `json:"duration"` | ||
|
||
// Length of time to create shard groups in. | ||
ShardGroupDuration time.Duration `json:"shardGroupDuration"` | ||
|
||
// The number of copies to make of each shard. | ||
ReplicaN uint32 `json:"replicaN"` | ||
|
||
|
@@ -1112,6 +1115,7 @@ func (rp *RetentionPolicy) MarshalJSON() ([]byte, error) { | |
var o retentionPolicyJSON | ||
o.Name = rp.Name | ||
o.Duration = rp.Duration | ||
o.ShardGroupDuration = rp.ShardGroupDuration | ||
o.ReplicaN = rp.ReplicaN | ||
for _, g := range rp.shardGroups { | ||
o.ShardGroups = append(o.ShardGroups, g) | ||
|
@@ -1131,18 +1135,20 @@ func (rp *RetentionPolicy) UnmarshalJSON(data []byte) error { | |
rp.Name = o.Name | ||
rp.ReplicaN = o.ReplicaN | ||
rp.Duration = o.Duration | ||
rp.ShardGroupDuration = o.ShardGroupDuration | ||
rp.shardGroups = o.ShardGroups | ||
|
||
return nil | ||
} | ||
|
||
// retentionPolicyJSON represents an intermediate struct for JSON marshaling. | ||
type retentionPolicyJSON struct { | ||
Name string `json:"name"` | ||
ReplicaN uint32 `json:"replicaN,omitempty"` | ||
SplitN uint32 `json:"splitN,omitempty"` | ||
Duration time.Duration `json:"duration,omitempty"` | ||
ShardGroups []*ShardGroup `json:"shardGroups,omitempty"` | ||
Name string `json:"name"` | ||
ReplicaN uint32 `json:"replicaN,omitempty"` | ||
SplitN uint32 `json:"splitN,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Duration time.Duration `json:"duration,omitempty"` | ||
ShardGroupDuration time.Duration `json:"shardGroupDuration"` | ||
ShardGroups []*ShardGroup `json:"shardGroups,omitempty"` | ||
} | ||
|
||
// TagFilter represents a tag filter when looking up other tags or measurements. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment does nothing to explain what the setting does.