1
0
Fork 0

Merge remote-tracking branch 'origin' into backup-forwarding

master
Philip O'Toole 2 years ago
commit 5cf7f8d920

@ -73,6 +73,8 @@ jobs:
command: python3 system_test/full_system_test.py command: python3 system_test/full_system_test.py
environment: environment:
RQLITED_PATH: /home/circleci/go/bin/rqlited RQLITED_PATH: /home/circleci/go/bin/rqlited
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
workflows: workflows:
version: 2 version: 2

@ -1,3 +1,8 @@
## 7.8.0 (unreleased)
### Implementation changes and bug fixes
- [PR #1079](https://github.com/rqlite/rqlite/pull/1079): Use a Protobuf model for Backup requests.
- [PR #1078](https://github.com/rqlite/rqlite/pull/1078): Decrease bootstrap polling interval from 5 seconds to 2 seconds.
## 7.7.2 (October 14th 2022) ## 7.7.2 (October 14th 2022)
### Implementation changes and bug fixes ### Implementation changes and bug fixes
- [PR #1075](https://github.com/rqlite/rqlite/pull/1075): Upgrade to latest SQL parser. Fixes [issue #1072](https://github.com/rqlite/rqlite/issues/1072) - [PR #1075](https://github.com/rqlite/rqlite/pull/1075): Upgrade to latest SQL parser. Fixes [issue #1072](https://github.com/rqlite/rqlite/issues/1072)

@ -69,6 +69,55 @@ func (QueryRequest_Level) EnumDescriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{3, 0} return file_command_proto_rawDescGZIP(), []int{3, 0}
} }
type BackupRequest_Format int32
const (
BackupRequest_BACKUP_REQUEST_FORMAT_NONE BackupRequest_Format = 0
BackupRequest_BACKUP_REQUEST_FORMAT_SQL BackupRequest_Format = 1
BackupRequest_BACKUP_REQUEST_FORMAT_BINARY BackupRequest_Format = 2
)
// Enum value maps for BackupRequest_Format.
var (
BackupRequest_Format_name = map[int32]string{
0: "BACKUP_REQUEST_FORMAT_NONE",
1: "BACKUP_REQUEST_FORMAT_SQL",
2: "BACKUP_REQUEST_FORMAT_BINARY",
}
BackupRequest_Format_value = map[string]int32{
"BACKUP_REQUEST_FORMAT_NONE": 0,
"BACKUP_REQUEST_FORMAT_SQL": 1,
"BACKUP_REQUEST_FORMAT_BINARY": 2,
}
)
func (x BackupRequest_Format) Enum() *BackupRequest_Format {
p := new(BackupRequest_Format)
*p = x
return p
}
func (x BackupRequest_Format) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (BackupRequest_Format) Descriptor() protoreflect.EnumDescriptor {
return file_command_proto_enumTypes[1].Descriptor()
}
func (BackupRequest_Format) Type() protoreflect.EnumType {
return &file_command_proto_enumTypes[1]
}
func (x BackupRequest_Format) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use BackupRequest_Format.Descriptor instead.
func (BackupRequest_Format) EnumDescriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{8, 0}
}
type Command_Type int32 type Command_Type int32
const ( const (
@ -108,11 +157,11 @@ func (x Command_Type) String() string {
} }
func (Command_Type) Descriptor() protoreflect.EnumDescriptor { func (Command_Type) Descriptor() protoreflect.EnumDescriptor {
return file_command_proto_enumTypes[1].Descriptor() return file_command_proto_enumTypes[2].Descriptor()
} }
func (Command_Type) Type() protoreflect.EnumType { func (Command_Type) Type() protoreflect.EnumType {
return &file_command_proto_enumTypes[1] return &file_command_proto_enumTypes[2]
} }
func (x Command_Type) Number() protoreflect.EnumNumber { func (x Command_Type) Number() protoreflect.EnumNumber {
@ -121,7 +170,7 @@ func (x Command_Type) Number() protoreflect.EnumNumber {
// Deprecated: Use Command_Type.Descriptor instead. // Deprecated: Use Command_Type.Descriptor instead.
func (Command_Type) EnumDescriptor() ([]byte, []int) { func (Command_Type) EnumDescriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{10, 0} return file_command_proto_rawDescGZIP(), []int{11, 0}
} }
type Parameter struct { type Parameter struct {
@ -687,6 +736,61 @@ func (x *ExecuteResult) GetTime() float64 {
return 0 return 0
} }
type BackupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Format BackupRequest_Format `protobuf:"varint,1,opt,name=format,proto3,enum=command.BackupRequest_Format" json:"format,omitempty"`
Leader bool `protobuf:"varint,2,opt,name=Leader,proto3" json:"Leader,omitempty"`
}
func (x *BackupRequest) Reset() {
*x = BackupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BackupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BackupRequest) ProtoMessage() {}
func (x *BackupRequest) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BackupRequest.ProtoReflect.Descriptor instead.
func (*BackupRequest) Descriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{8}
}
func (x *BackupRequest) GetFormat() BackupRequest_Format {
if x != nil {
return x.Format
}
return BackupRequest_BACKUP_REQUEST_FORMAT_NONE
}
func (x *BackupRequest) GetLeader() bool {
if x != nil {
return x.Leader
}
return false
}
type LoadRequest struct { type LoadRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@ -698,7 +802,7 @@ type LoadRequest struct {
func (x *LoadRequest) Reset() { func (x *LoadRequest) Reset() {
*x = LoadRequest{} *x = LoadRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[8] mi := &file_command_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -711,7 +815,7 @@ func (x *LoadRequest) String() string {
func (*LoadRequest) ProtoMessage() {} func (*LoadRequest) ProtoMessage() {}
func (x *LoadRequest) ProtoReflect() protoreflect.Message { func (x *LoadRequest) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[8] mi := &file_command_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -724,7 +828,7 @@ func (x *LoadRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use LoadRequest.ProtoReflect.Descriptor instead. // Deprecated: Use LoadRequest.ProtoReflect.Descriptor instead.
func (*LoadRequest) Descriptor() ([]byte, []int) { func (*LoadRequest) Descriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{8} return file_command_proto_rawDescGZIP(), []int{9}
} }
func (x *LoadRequest) GetData() []byte { func (x *LoadRequest) GetData() []byte {
@ -745,7 +849,7 @@ type Noop struct {
func (x *Noop) Reset() { func (x *Noop) Reset() {
*x = Noop{} *x = Noop{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[9] mi := &file_command_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -758,7 +862,7 @@ func (x *Noop) String() string {
func (*Noop) ProtoMessage() {} func (*Noop) ProtoMessage() {}
func (x *Noop) ProtoReflect() protoreflect.Message { func (x *Noop) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[9] mi := &file_command_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -771,7 +875,7 @@ func (x *Noop) ProtoReflect() protoreflect.Message {
// Deprecated: Use Noop.ProtoReflect.Descriptor instead. // Deprecated: Use Noop.ProtoReflect.Descriptor instead.
func (*Noop) Descriptor() ([]byte, []int) { func (*Noop) Descriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{9} return file_command_proto_rawDescGZIP(), []int{10}
} }
func (x *Noop) GetId() string { func (x *Noop) GetId() string {
@ -794,7 +898,7 @@ type Command struct {
func (x *Command) Reset() { func (x *Command) Reset() {
*x = Command{} *x = Command{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_command_proto_msgTypes[10] mi := &file_command_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@ -807,7 +911,7 @@ func (x *Command) String() string {
func (*Command) ProtoMessage() {} func (*Command) ProtoMessage() {}
func (x *Command) ProtoReflect() protoreflect.Message { func (x *Command) ProtoReflect() protoreflect.Message {
mi := &file_command_proto_msgTypes[10] mi := &file_command_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@ -820,7 +924,7 @@ func (x *Command) ProtoReflect() protoreflect.Message {
// Deprecated: Use Command.ProtoReflect.Descriptor instead. // Deprecated: Use Command.ProtoReflect.Descriptor instead.
func (*Command) Descriptor() ([]byte, []int) { func (*Command) Descriptor() ([]byte, []int) {
return file_command_proto_rawDescGZIP(), []int{10} return file_command_proto_rawDescGZIP(), []int{11}
} }
func (x *Command) GetType() Command_Type { func (x *Command) GetType() Command_Type {
@ -911,29 +1015,41 @@ var file_command_proto_rawDesc = []byte{
0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x66, 0x66, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x12, 0x0a, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x12, 0x0a,
0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x04, 0x74, 0x69, 0x6d,
0x65, 0x22, 0x21, 0x0a, 0x0b, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x22, 0xc9, 0x01, 0x0a, 0x0d, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75,
0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x65, 0x73, 0x74, 0x12, 0x35, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x01, 0x20,
0x64, 0x61, 0x74, 0x61, 0x22, 0x16, 0x0a, 0x04, 0x4e, 0x6f, 0x6f, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x01, 0x28, 0x0e, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x42, 0x61,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xf8, 0x01, 0x0a, 0x63, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x6f, 0x72, 0x6d,
0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x61, 0x74, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x4c, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x4c, 0x65, 0x61, 0x64,
0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x65, 0x72, 0x22, 0x69, 0x0a, 0x06, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x1e, 0x0a, 0x1a,
0x79, 0x70, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x42, 0x41, 0x43, 0x4b, 0x55, 0x50, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x46,
0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x43, 0x6f, 0x6d, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19,
0x6d, 0x61, 0x6e, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x42, 0x41, 0x43, 0x4b, 0x55, 0x50, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x46,
0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x53, 0x51, 0x4c, 0x10, 0x01, 0x12, 0x20, 0x0a, 0x1c, 0x42,
0x73, 0x73, 0x65, 0x64, 0x22, 0x80, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x41, 0x43, 0x4b, 0x55, 0x50, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x5f, 0x46, 0x4f,
0x14, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x10, 0x02, 0x22, 0x21, 0x0a,
0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x0b, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x22, 0x16, 0x0a, 0x04, 0x4e, 0x6f, 0x6f, 0x70, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0xf8, 0x01, 0x0a, 0x07, 0x43, 0x6f, 0x6d,
0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4f, 0x50, 0x10, 0x03, 0x6d, 0x61, 0x6e, 0x64, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x43, 0x6f, 0x6d,
0x5f, 0x4c, 0x4f, 0x41, 0x44, 0x10, 0x04, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x72, 0x71, 0x6c, 0x1f, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02,
0x69, 0x74, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0a, 0x73, 0x75, 0x62, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64,
0x74, 0x6f, 0x33, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x18, 0x03,
0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64,
0x22, 0x80, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4d,
0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57,
0x4e, 0x10, 0x00, 0x12, 0x16, 0x0a, 0x12, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54,
0x59, 0x50, 0x45, 0x5f, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x01, 0x12, 0x18, 0x0a, 0x14, 0x43,
0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x58, 0x45, 0x43,
0x55, 0x54, 0x45, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44,
0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4f, 0x50, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11,
0x43, 0x4f, 0x4d, 0x4d, 0x41, 0x4e, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4c, 0x4f, 0x41,
0x44, 0x10, 0x04, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x72, 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f, 0x72, 0x71, 0x6c, 0x69, 0x74, 0x65, 0x2f,
0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -948,37 +1064,40 @@ func file_command_proto_rawDescGZIP() []byte {
return file_command_proto_rawDescData return file_command_proto_rawDescData
} }
var file_command_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_command_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_command_proto_goTypes = []interface{}{ var file_command_proto_goTypes = []interface{}{
(QueryRequest_Level)(0), // 0: command.QueryRequest.Level (QueryRequest_Level)(0), // 0: command.QueryRequest.Level
(Command_Type)(0), // 1: command.Command.Type (BackupRequest_Format)(0), // 1: command.BackupRequest.Format
(*Parameter)(nil), // 2: command.Parameter (Command_Type)(0), // 2: command.Command.Type
(*Statement)(nil), // 3: command.Statement (*Parameter)(nil), // 3: command.Parameter
(*Request)(nil), // 4: command.Request (*Statement)(nil), // 4: command.Statement
(*QueryRequest)(nil), // 5: command.QueryRequest (*Request)(nil), // 5: command.Request
(*Values)(nil), // 6: command.Values (*QueryRequest)(nil), // 6: command.QueryRequest
(*QueryRows)(nil), // 7: command.QueryRows (*Values)(nil), // 7: command.Values
(*ExecuteRequest)(nil), // 8: command.ExecuteRequest (*QueryRows)(nil), // 8: command.QueryRows
(*ExecuteResult)(nil), // 9: command.ExecuteResult (*ExecuteRequest)(nil), // 9: command.ExecuteRequest
(*LoadRequest)(nil), // 10: command.LoadRequest (*ExecuteResult)(nil), // 10: command.ExecuteResult
(*Noop)(nil), // 11: command.Noop (*BackupRequest)(nil), // 11: command.BackupRequest
(*Command)(nil), // 12: command.Command (*LoadRequest)(nil), // 12: command.LoadRequest
(*Noop)(nil), // 13: command.Noop
(*Command)(nil), // 14: command.Command
} }
var file_command_proto_depIdxs = []int32{ var file_command_proto_depIdxs = []int32{
2, // 0: command.Statement.parameters:type_name -> command.Parameter 3, // 0: command.Statement.parameters:type_name -> command.Parameter
3, // 1: command.Request.statements:type_name -> command.Statement 4, // 1: command.Request.statements:type_name -> command.Statement
4, // 2: command.QueryRequest.request:type_name -> command.Request 5, // 2: command.QueryRequest.request:type_name -> command.Request
0, // 3: command.QueryRequest.level:type_name -> command.QueryRequest.Level 0, // 3: command.QueryRequest.level:type_name -> command.QueryRequest.Level
2, // 4: command.Values.parameters:type_name -> command.Parameter 3, // 4: command.Values.parameters:type_name -> command.Parameter
6, // 5: command.QueryRows.values:type_name -> command.Values 7, // 5: command.QueryRows.values:type_name -> command.Values
4, // 6: command.ExecuteRequest.request:type_name -> command.Request 5, // 6: command.ExecuteRequest.request:type_name -> command.Request
1, // 7: command.Command.type:type_name -> command.Command.Type 1, // 7: command.BackupRequest.format:type_name -> command.BackupRequest.Format
8, // [8:8] is the sub-list for method output_type 2, // 8: command.Command.type:type_name -> command.Command.Type
8, // [8:8] is the sub-list for method input_type 9, // [9:9] is the sub-list for method output_type
8, // [8:8] is the sub-list for extension type_name 9, // [9:9] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension extendee 9, // [9:9] is the sub-list for extension type_name
0, // [0:8] is the sub-list for field type_name 9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
} }
func init() { file_command_proto_init() } func init() { file_command_proto_init() }
@ -1084,7 +1203,7 @@ func file_command_proto_init() {
} }
} }
file_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { file_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoadRequest); i { switch v := v.(*BackupRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -1096,7 +1215,7 @@ func file_command_proto_init() {
} }
} }
file_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { file_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Noop); i { switch v := v.(*LoadRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@ -1108,6 +1227,18 @@ func file_command_proto_init() {
} }
} }
file_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { file_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Noop); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Command); i { switch v := v.(*Command); i {
case 0: case 0:
return &v.state return &v.state
@ -1132,8 +1263,8 @@ func file_command_proto_init() {
File: protoimpl.DescBuilder{ File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_command_proto_rawDesc, RawDescriptor: file_command_proto_rawDesc,
NumEnums: 2, NumEnums: 3,
NumMessages: 11, NumMessages: 12,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

@ -60,6 +60,16 @@ message ExecuteResult {
double time = 4; double time = 4;
} }
message BackupRequest {
enum Format {
BACKUP_REQUEST_FORMAT_NONE = 0;
BACKUP_REQUEST_FORMAT_SQL = 1;
BACKUP_REQUEST_FORMAT_BINARY = 2;
}
Format format = 1;
bool Leader = 2;
}
message LoadRequest { message LoadRequest {
bytes data = 1; bytes data = 1;
} }

@ -80,7 +80,7 @@ type Store interface {
Nodes() ([]*store.Server, error) Nodes() ([]*store.Server, error)
// Backup wites backup of the node state to dst // Backup wites backup of the node state to dst
Backup(leader bool, f store.BackupFormat, dst io.Writer) error Backup(br *command.BackupRequest, dst io.Writer) error
} }
// Cluster is the interface node API services must provide // Cluster is the interface node API services must provide
@ -572,7 +572,12 @@ func (s *Service) handleBackup(w http.ResponseWriter, r *http.Request) {
return return
} }
err = s.store.Backup(!noLeader, bf, w) br := &command.BackupRequest{
Format: bf,
Leader: !noLeader,
}
err = s.store.Backup(br, w)
if err != nil { if err != nil {
if err == store.ErrNotLeader { if err == store.ErrNotLeader {
leaderAPIAddr := s.LeaderAPIAddr() leaderAPIAddr := s.LeaderAPIAddr()
@ -1661,17 +1666,17 @@ func freshness(req *http.Request) (time.Duration, error) {
// backupFormat returns the request backup format, setting the response header // backupFormat returns the request backup format, setting the response header
// accordingly. // accordingly.
func backupFormat(w http.ResponseWriter, r *http.Request) (store.BackupFormat, error) { func backupFormat(w http.ResponseWriter, r *http.Request) (command.BackupRequest_Format, error) {
fmt, err := fmtParam(r) fmt, err := fmtParam(r)
if err != nil { if err != nil {
return store.BackupBinary, err return command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY, err
} }
if fmt == "sql" { if fmt == "sql" {
w.Header().Set("Content-Type", "application/sql") w.Header().Set("Content-Type", "application/sql")
return store.BackupSQL, nil return command.BackupRequest_BACKUP_REQUEST_FORMAT_SQL, nil
} }
w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Type", "application/octet-stream")
return store.BackupBinary, nil return command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY, nil
} }
func prettyEnabled(e bool) string { func prettyEnabled(e bool) string {

@ -564,7 +564,7 @@ func Test_BackupOK(t *testing.T) {
} }
defer s.Close() defer s.Close()
m.backupFn = func(leader bool, f store.BackupFormat, dst io.Writer) error { m.backupFn = func(br *command.BackupRequest, dst io.Writer) error {
return nil return nil
} }
@ -592,7 +592,7 @@ func Test_BackupFlagsNoLeader(t *testing.T) {
} }
defer s.Close() defer s.Close()
m.backupFn = func(leader bool, f store.BackupFormat, dst io.Writer) error { m.backupFn = func(br *command.BackupRequest, dst io.Writer) error {
return store.ErrNotLeader return store.ErrNotLeader
} }
@ -624,8 +624,8 @@ func Test_BackupFlagsNoLeaderOK(t *testing.T) {
} }
defer s.Close() defer s.Close()
m.backupFn = func(leader bool, f store.BackupFormat, dst io.Writer) error { m.backupFn = func(br *command.BackupRequest, dst io.Writer) error {
if !leader { if !br.Leader {
return nil return nil
} }
return store.ErrNotLeader return store.ErrNotLeader
@ -1000,7 +1000,7 @@ func Test_timeoutQueryParam(t *testing.T) {
type MockStore struct { type MockStore struct {
executeFn func(er *command.ExecuteRequest) ([]*command.ExecuteResult, error) executeFn func(er *command.ExecuteRequest) ([]*command.ExecuteResult, error)
queryFn func(qr *command.QueryRequest) ([]*command.QueryRows, error) queryFn func(qr *command.QueryRequest) ([]*command.QueryRows, error)
backupFn func(leader bool, f store.BackupFormat, dst io.Writer) error backupFn func(br *command.BackupRequest, dst io.Writer) error
leaderAddr string leaderAddr string
} }
@ -1046,11 +1046,11 @@ func (m *MockStore) Nodes() ([]*store.Server, error) {
return nil, nil return nil, nil
} }
func (m *MockStore) Backup(leader bool, f store.BackupFormat, w io.Writer) error { func (m *MockStore) Backup(br *command.BackupRequest, w io.Writer) error {
if m.backupFn == nil { if m.backupFn == nil {
return nil return nil
} }
return m.backupFn(leader, f, w) return m.backupFn(br, w)
} }
type mockClusterService struct { type mockClusterService struct {

@ -86,17 +86,6 @@ const (
leaderChangesDropped = "leader_changes_dropped" leaderChangesDropped = "leader_changes_dropped"
) )
// BackupFormat represents the format of database backup.
type BackupFormat int
const (
// BackupSQL is the plaintext SQL command format.
BackupSQL BackupFormat = iota
// BackupBinary is a SQLite file backup format.
BackupBinary
)
// stats captures stats for the Store. // stats captures stats for the Store.
var stats *expvar.Map var stats *expvar.Map
@ -820,19 +809,18 @@ func (s *Store) Query(qr *command.QueryRequest) ([]*command.QueryRows, error) {
// Backup writes a snapshot of the underlying database to dst // Backup writes a snapshot of the underlying database to dst
// //
// If leader is true, this operation is performed with a read consistency // If Leader is true for the request, this operation is performed with a read consistency
// level equivalent to "weak". Otherwise, no guarantees are made about the // level equivalent to "weak". Otherwise, no guarantees are made about the read consistency level.
// read consistency level. func (s *Store) Backup(br *command.BackupRequest, dst io.Writer) error {
func (s *Store) Backup(leader bool, fmt BackupFormat, dst io.Writer) error { if br.Leader && s.raft.State() != raft.Leader {
if leader && s.raft.State() != raft.Leader {
return ErrNotLeader return ErrNotLeader
} }
if fmt == BackupBinary { if br.Format == command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY {
if err := s.database(leader, dst); err != nil { if err := s.database(br.Leader, dst); err != nil {
return err return err
} }
} else if fmt == BackupSQL { } else if br.Format == command.BackupRequest_BACKUP_REQUEST_FORMAT_SQL {
if err := s.db.Dump(dst); err != nil { if err := s.db.Dump(dst); err != nil {
return err return err
} }

@ -476,7 +476,7 @@ COMMIT;
defer os.Remove(f.Name()) defer os.Remove(f.Name())
s.logger.Printf("backup file is %s", f.Name()) s.logger.Printf("backup file is %s", f.Name())
if err := s.Backup(true, BackupBinary, f); err != nil { if err := s.Backup(backupRequestBinary(true), f); err != nil {
t.Fatalf("Backup failed %s", err.Error()) t.Fatalf("Backup failed %s", err.Error())
} }
@ -530,7 +530,7 @@ COMMIT;
defer os.Remove(f.Name()) defer os.Remove(f.Name())
s.logger.Printf("backup file is %s", f.Name()) s.logger.Printf("backup file is %s", f.Name())
if err := s.Backup(true, BackupSQL, f); err != nil { if err := s.Backup(backupRequestSQL(true), f); err != nil {
t.Fatalf("Backup failed %s", err.Error()) t.Fatalf("Backup failed %s", err.Error())
} }
@ -2137,6 +2137,20 @@ func queryRequestFromStrings(s []string, timings, tx bool) *command.QueryRequest
} }
} }
func backupRequestSQL(leader bool) *command.BackupRequest {
return &command.BackupRequest{
Format: command.BackupRequest_BACKUP_REQUEST_FORMAT_SQL,
Leader: leader,
}
}
func backupRequestBinary(leader bool) *command.BackupRequest {
return &command.BackupRequest{
Format: command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY,
Leader: leader,
}
}
func loadRequestFromFile(path string) *command.LoadRequest { func loadRequestFromFile(path string) *command.LoadRequest {
return &command.LoadRequest{ return &command.LoadRequest{
Data: mustReadFile(path), Data: mustReadFile(path),

Loading…
Cancel
Save