diff --git a/broadcast.go b/broadcast.go index 883b62436..bb32ab0ba 100644 --- a/broadcast.go +++ b/broadcast.go @@ -137,6 +137,7 @@ const ( MessageTypeResizeInstructionComplete MessageTypeSetCoordinator MessageTypeNodeState + MessageTypeRecalculateCaches ) // MarshalMessage encodes the protobuf message into a byte slice. @@ -171,6 +172,8 @@ func MarshalMessage(m proto.Message) ([]byte, error) { typ = MessageTypeSetCoordinator case *internal.NodeStateMessage: typ = MessageTypeNodeState + case *internal.RecalculateCaches: + typ = MessageTypeRecalculateCaches default: return nil, fmt.Errorf("message type not implemented for marshalling: %s", reflect.TypeOf(obj)) } @@ -215,6 +218,8 @@ func UnmarshalMessage(buf []byte) (proto.Message, error) { m = &internal.SetCoordinatorMessage{} case MessageTypeNodeState: m = &internal.NodeStateMessage{} + case MessageTypeRecalculateCaches: + m = &internal.RecalculateCaches{} default: return nil, fmt.Errorf("invalid message type: %d", typ) } diff --git a/handler.go b/handler.go index dd438e977..ff591a568 100644 --- a/handler.go +++ b/handler.go @@ -2151,6 +2151,12 @@ func (h *Handler) InputJSONDataParser(req map[string]interface{}, index *Index, } func (h *Handler) handleRecalculateCaches(w http.ResponseWriter, r *http.Request) { + err := h.Broadcaster.SendSync(&internal.RecalculateCaches{}) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + h.writeQueryResponse(w, r, &QueryResponse{Err: err}) + return + } h.Holder.RecalculateCaches() w.WriteHeader(http.StatusNoContent) } diff --git a/internal/private.pb.go b/internal/private.pb.go index b584a10a9..3ea095687 100644 --- a/internal/private.pb.go +++ b/internal/private.pb.go @@ -42,6 +42,7 @@ ResizeInstructionComplete SetCoordinatorMessage Topology + RecalculateCaches */ package internal @@ -1068,6 +1069,14 @@ func (m *Topology) GetNodeIDs() []string { return nil } +type RecalculateCaches struct { +} + +func (m *RecalculateCaches) Reset() { *m = RecalculateCaches{} } +func (m *RecalculateCaches) String() string { return proto.CompactTextString(m) } +func (*RecalculateCaches) ProtoMessage() {} +func (*RecalculateCaches) Descriptor() ([]byte, []int) { return fileDescriptorPrivate, []int{33} } + func init() { proto.RegisterType((*IndexMeta)(nil), "internal.IndexMeta") proto.RegisterType((*FrameMeta)(nil), "internal.FrameMeta") @@ -1102,6 +1111,7 @@ func init() { proto.RegisterType((*ResizeInstructionComplete)(nil), "internal.ResizeInstructionComplete") proto.RegisterType((*SetCoordinatorMessage)(nil), "internal.SetCoordinatorMessage") proto.RegisterType((*Topology)(nil), "internal.Topology") + proto.RegisterType((*RecalculateCaches)(nil), "internal.RecalculateCaches") } func (m *IndexMeta) Marshal() (dAtA []byte, err error) { size := m.Size() @@ -2449,6 +2459,24 @@ func (m *Topology) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *RecalculateCaches) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RecalculateCaches) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + func encodeFixed64Private(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) dAtA[offset+1] = uint8(v >> 8) @@ -3070,6 +3098,12 @@ func (m *Topology) Size() (n int) { return n } +func (m *RecalculateCaches) Size() (n int) { + var l int + _ = l + return n +} + func sovPrivate(x uint64) (n int) { for { n++ @@ -7663,6 +7697,56 @@ func (m *Topology) Unmarshal(dAtA []byte) error { } return nil } +func (m *RecalculateCaches) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPrivate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RecalculateCaches: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecalculateCaches: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipPrivate(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthPrivate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipPrivate(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -7771,84 +7855,84 @@ var ( func init() { proto.RegisterFile("private.proto", fileDescriptorPrivate) } var fileDescriptorPrivate = []byte{ - // 1250 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x5d, 0x6f, 0x1b, 0x45, - 0x17, 0x7e, 0xd7, 0xbb, 0x76, 0xec, 0xe3, 0x38, 0x71, 0xe6, 0x4d, 0x83, 0x13, 0x45, 0xae, 0x19, - 0x21, 0x1a, 0x2a, 0x11, 0x15, 0x57, 0x02, 0x1a, 0x54, 0xa9, 0x24, 0x76, 0xd5, 0x05, 0x12, 0xca, - 0x38, 0x2d, 0x12, 0x17, 0x48, 0x13, 0x7b, 0x48, 0x57, 0x59, 0xef, 0x9a, 0xdd, 0x71, 0x12, 0xf7, - 0x82, 0x4b, 0x84, 0x84, 0xb8, 0x47, 0xdc, 0xf2, 0x67, 0xb8, 0xe4, 0x27, 0xa0, 0xf0, 0x23, 0x90, - 0xb8, 0x01, 0xcd, 0xd7, 0xee, 0xfa, 0x33, 0xa4, 0x70, 0xb7, 0xe7, 0x39, 0x1f, 0xf3, 0xcc, 0x39, - 0x67, 0xce, 0xcc, 0x42, 0x65, 0x10, 0x79, 0xe7, 0x94, 0xb3, 0xdd, 0x41, 0x14, 0xf2, 0x10, 0x15, - 0xbd, 0x80, 0xb3, 0x28, 0xa0, 0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b, 0x1a, 0x46, - 0x5c, 0x32, 0xae, 0x10, 0xf9, 0x8d, 0xdf, 0x03, 0xe7, 0x28, 0xec, 0x31, 0xb4, 0x02, 0x39, 0xb7, - 0xa5, 0x63, 0xe4, 0xdc, 0x16, 0xba, 0x2d, 0xc3, 0xeb, 0x19, 0x52, 0x49, 0x37, 0xf7, 0x8c, 0xb8, - 0x44, 0x68, 0xf0, 0x23, 0xa8, 0x0a, 0xc7, 0x0e, 0xa7, 0x3c, 0x19, 0x61, 0x1b, 0x50, 0x10, 0x58, - 0x12, 0x48, 0x4b, 0xf2, 0x42, 0x10, 0x76, 0x66, 0x88, 0x49, 0x01, 0xff, 0x60, 0x01, 0x98, 0x10, - 0xc3, 0x18, 0x61, 0xc5, 0x44, 0xba, 0x96, 0x9b, 0x2b, 0xe9, 0x92, 0x02, 0x25, 0x8a, 0xe5, 0x3b, - 0x99, 0x6b, 0x78, 0x7a, 0xbe, 0x25, 0x2a, 0x92, 0xb9, 0xac, 0x77, 0xcc, 0x38, 0xd3, 0x85, 0xaa, - 0xa6, 0xf6, 0x0a, 0xd7, 0x29, 0x13, 0x37, 0x40, 0xe5, 0xc0, 0x1f, 0xc6, 0x9c, 0x45, 0x9a, 0x91, - 0x78, 0x2e, 0x28, 0x20, 0xd9, 0x51, 0x0a, 0xcc, 0xde, 0x14, 0x7a, 0x03, 0xf2, 0x82, 0xa9, 0x39, - 0x93, 0x93, 0xdb, 0x50, 0x4a, 0xdc, 0x81, 0xfc, 0xfc, 0x39, 0x80, 0xc0, 0x91, 0x8f, 0x43, 0x5d, - 0x3a, 0xf9, 0x2e, 0xac, 0x82, 0x7d, 0xe8, 0xa9, 0x5e, 0xb3, 0x89, 0xf8, 0x94, 0x08, 0xbd, 0x94, - 0x67, 0x41, 0x20, 0x54, 0x5c, 0x8b, 0x6b, 0xaa, 0x99, 0xc5, 0x1c, 0x7f, 0x95, 0x0b, 0xcc, 0xbc, - 0xaf, 0xec, 0xcc, 0xfb, 0xaa, 0x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 0xee, 0x57, 0x7f, 0xb9, - 0xaa, 0x5b, 0xbf, 0x5e, 0xd5, 0xad, 0xdf, 0xae, 0xea, 0xd6, 0x8f, 0xbf, 0xd7, 0xff, 0x77, 0x52, - 0x90, 0x7f, 0x97, 0xf7, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xc5, 0x2e, 0x66, 0x6e, 0x0e, - 0x00, 0x00, + // 1263 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0x67, 0xbd, 0xb6, 0x63, 0x3f, 0xd7, 0x89, 0x33, 0x4d, 0x83, 0x13, 0x45, 0xae, 0x19, 0x21, + 0x1a, 0x2a, 0x11, 0x15, 0x57, 0x02, 0x1a, 0x54, 0xa9, 0x24, 0x76, 0xd5, 0x05, 0x12, 0xca, 0x38, + 0x2d, 0x12, 0x07, 0xa4, 0x89, 0x3d, 0xa4, 0xab, 0xac, 0x77, 0xcd, 0xee, 0x6c, 0x12, 0xf7, 0xc0, + 0x11, 0x21, 0x21, 0xee, 0x88, 0x2b, 0x5f, 0x86, 0x23, 0x1f, 0x01, 0x85, 0x0f, 0x81, 0xc4, 0x05, + 0x34, 0xff, 0x76, 0xd7, 0x7f, 0x43, 0x0a, 0xb7, 0x7d, 0xbf, 0xf7, 0x67, 0x7e, 0xf3, 0xde, 0x9b, + 0x37, 0xb3, 0x50, 0x1d, 0x86, 0xee, 0x19, 0xe5, 0x6c, 0x67, 0x18, 0x06, 0x3c, 0x40, 0x25, 0xd7, + 0xe7, 0x2c, 0xf4, 0xa9, 0x87, 0x3f, 0x83, 0xb2, 0xe3, 0xf7, 0xd9, 0xc5, 0x01, 0xe3, 0x14, 0x35, + 0xa1, 0xb2, 0x1f, 0x78, 0xf1, 0xc0, 0xff, 0x94, 0x1e, 0x33, 0xaf, 0x6e, 0x35, 0xad, 0xed,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x86, 0xf5, 0xd3, 0x1f, 0x8d, 0xd7, 0x8e, 0x8b, 0xf2, 0x97, 0xf3, + 0xfe, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x2d, 0x85, 0x72, 0x83, 0x0e, 0x00, 0x00, } diff --git a/internal/private.proto b/internal/private.proto index 4e3261079..ccf2b1c74 100644 --- a/internal/private.proto +++ b/internal/private.proto @@ -194,3 +194,4 @@ message Topology { repeated string NodeIDs = 2; } +message RecalculateCaches {} diff --git a/server.go b/server.go index 63c14a88e..a3143cbf3 100644 --- a/server.go +++ b/server.go @@ -448,6 +448,8 @@ func (s *Server) ReceiveMessage(pb proto.Message) error { if err != nil { return err } + case *internal.RecalculateCaches: + s.Holder.RecalculateCaches() } return nil diff --git a/server/server_test.go b/server/server_test.go index c821ccdf8..3852845a6 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -23,6 +23,7 @@ import ( "reflect" "runtime" "sort" + "strings" "testing" "testing/quick" @@ -383,6 +384,47 @@ func TestCountOpenFiles(t *testing.T) { } } +func TestMain_RecalculateHashes(t *testing.T) { + const clusterSize = 5 + cluster := test.MustRunMainWithCluster(t, clusterSize) + + // Create the schema. + client0 := cluster[0].Client() + if err := client0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists { + t.Fatal("create index:", err) + } + if err := client0.CreateFrame(context.Background(), "i", "f", pilosa.FrameOptions{CacheType: "ranked"}); err != nil { + t.Fatal("create frame:", err) + } + + // Set some bits + data := []string{} + for rowID := 1; rowID < 10; rowID++ { + for columnID := 1; columnID < 100; columnID++ { + data = append(data, fmt.Sprintf(`SetBit(rowID=%d, frame="f", columnID=%d)`, rowID, columnID)) + } + } + if _, err := cluster[0].Query("i", "", strings.Join(data, "")); err != nil { + t.Fatal("setting bits:", err) + } + + // Calculate caches on the first node + cluster[0].RecalculateCaches() + target := `{"results":[[{"id":7,"count":99},{"id":1,"count":99},{"id":9,"count":99},{"id":5,"count":99},{"id":4,"count":99},{"id":8,"count":99},{"id":2,"count":99},{"id":6,"count":99},{"id":3,"count":99}]]}` + + // Run a TopN query on all nodes. The result should be the same as the target. + for _, m := range cluster { + res, err := m.Query("i", "", `TopN(frame="f")`) + if err != nil { + t.Fatal(err) + } + res = strings.TrimSpace(res) + if sortedString(target) != sortedString(res) { + t.Fatalf("%v != %v", target, res) + } + } +} + // SetCommand represents a command to set a bit. type SetCommand struct { ID uint64 @@ -448,6 +490,12 @@ func MustMarshalJSON(v interface{}) string { return string(buf) } +func sortedString(s string) string { + arr := strings.Split(s, "") + sort.Strings(arr) + return strings.Join(arr, "") +} + // uint64Slice represents a sortable slice of uint64 numbers. type uint64Slice []uint64 diff --git a/test/pilosa.go b/test/pilosa.go index b5d745fe0..7083b07b7 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -227,6 +227,14 @@ func (m *Main) CreateDefinition(index, def, query string) (string, error) { return resp.Body, nil } +func (m *Main) RecalculateCaches() error { + resp := MustDo("POST", fmt.Sprintf("%s/recalculate-caches", m.URL()), "") + if resp.StatusCode != 204 { + return fmt.Errorf("invalid status: %d, body=%s", resp.StatusCode, resp.Body) + } + return nil +} + //////////////////////////////////////////////////////////////////////////////////// // MustDo executes http.Do() with an http.NewRequest(). Panic on error.