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
environment:
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:
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)
### 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)

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

@ -60,6 +60,16 @@ message ExecuteResult {
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 {
bytes data = 1;
}

@ -80,7 +80,7 @@ type Store interface {
Nodes() ([]*store.Server, error)
// 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
@ -572,7 +572,12 @@ func (s *Service) handleBackup(w http.ResponseWriter, r *http.Request) {
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 == store.ErrNotLeader {
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
// 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)
if err != nil {
return store.BackupBinary, err
return command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY, err
}
if fmt == "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")
return store.BackupBinary, nil
return command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY, nil
}
func prettyEnabled(e bool) string {

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

@ -86,17 +86,6 @@ const (
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.
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
//
// If leader is true, this operation is performed with a read consistency
// level equivalent to "weak". Otherwise, no guarantees are made about the
// read consistency level.
func (s *Store) Backup(leader bool, fmt BackupFormat, dst io.Writer) error {
if leader && s.raft.State() != raft.Leader {
// 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 read consistency level.
func (s *Store) Backup(br *command.BackupRequest, dst io.Writer) error {
if br.Leader && s.raft.State() != raft.Leader {
return ErrNotLeader
}
if fmt == BackupBinary {
if err := s.database(leader, dst); err != nil {
if br.Format == command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY {
if err := s.database(br.Leader, dst); err != nil {
return err
}
} else if fmt == BackupSQL {
} else if br.Format == command.BackupRequest_BACKUP_REQUEST_FORMAT_SQL {
if err := s.db.Dump(dst); err != nil {
return err
}

@ -476,7 +476,7 @@ COMMIT;
defer os.Remove(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())
}
@ -530,7 +530,7 @@ COMMIT;
defer os.Remove(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())
}
@ -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 {
return &command.LoadRequest{
Data: mustReadFile(path),

Loading…
Cancel
Save