Skip to content
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

Cleanup pushdown terminology #3691

Merged
merged 31 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c7fb045
wip
noisersup Nov 9, 2023
2877a31
wip
noisersup Nov 9, 2023
cb7b85d
unsafe removal part uno
noisersup Nov 9, 2023
143c9dd
unsafe removal part dos
noisersup Nov 9, 2023
6926153
unsafe removal part drei
noisersup Nov 9, 2023
a68f056
unsafe removal part quatro
noisersup Nov 9, 2023
6e85bf0
Merge remote-tracking branch 'upstream/main' into cleanup-pushdown-te…
noisersup Nov 13, 2023
24dc52a
wip
noisersup Nov 14, 2023
15a2077
wip
noisersup Nov 15, 2023
84ad078
separate flags
noisersup Nov 15, 2023
94ee984
wip
noisersup Nov 15, 2023
9fce730
wip
noisersup Nov 15, 2023
bd2dcc2
wip
noisersup Nov 15, 2023
7e61b95
wip
noisersup Nov 15, 2023
4a03d61
wip
noisersup Nov 15, 2023
069ea9a
wip
noisersup Nov 15, 2023
bedd581
wip
noisersup Nov 15, 2023
f913767
wip
noisersup Nov 15, 2023
acc73fe
Merge branch 'main' into cleanup-pushdown-term-3688
AlekSi Nov 16, 2023
2adeed3
split
noisersup Nov 16, 2023
8f901f4
cleanup
noisersup Nov 16, 2023
2c7f43e
Merge branch 'main' into cleanup-pushdown-term-3688
AlekSi Nov 17, 2023
a7e17e2
rename
noisersup Nov 17, 2023
52568d8
rename
noisersup Nov 17, 2023
5aaf0c8
rm docs
noisersup Nov 17, 2023
68db116
fix
noisersup Nov 17, 2023
2016d9b
fix
noisersup Nov 17, 2023
2852ea9
fix
noisersup Nov 17, 2023
3bd7e92
Merge remote-tracking branch 'upstream/main' into cleanup-pushdown-te…
noisersup Nov 17, 2023
48e93df
Merge branch 'main' into cleanup-pushdown-term-3688
mergify[bot] Nov 20, 2023
8416137
Merge branch 'main' into cleanup-pushdown-term-3688
mergify[bot] Nov 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
separate flags
  • Loading branch information
noisersup committed Nov 15, 2023
commit 84ad078b5d4f56a9b03acdc6d12d7169a015a78e
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vars:
SHARD_TOTAL: 1
DISABLE_FILTER_PUSHDOWN: false
ENABLE_SORT_PUSHDOWN: false
ENABLE_UNSAFE_SORT_PUSHDOWN: false
TEST_RUN: ""
TEST_TIMEOUT: 35m
BENCH_TIME: 5s
Expand Down Expand Up @@ -219,6 +220,7 @@ tasks:
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
-disable-filter-pushdown={{.DISABLE_FILTER_PUSHDOWN}}
-enable-sort-pushdown={{.ENABLE_SORT_PUSHDOWN}}
-enable-unsafe-sort-pushdown={{.ENABLE_UNSAFE_SORT_PUSHDOWN}}

test-integration-sqlite:
desc: "Run integration tests for `sqlite` backend"
Expand All @@ -245,6 +247,7 @@ tasks:
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
-disable-filter-pushdown={{.DISABLE_FILTER_PUSHDOWN}}
-enable-sort-pushdown={{.ENABLE_SORT_PUSHDOWN}}
-enable-unsafe-sort-pushdown={{.ENABLE_UNSAFE_SORT_PUSHDOWN}}

test-integration-hana:
desc: "Run integration tests for `hana` handler"
Expand All @@ -271,6 +274,7 @@ tasks:
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
-disable-filter-pushdown={{.DISABLE_FILTER_PUSHDOWN}}
-enable-sort-pushdown={{.ENABLE_SORT_PUSHDOWN}}
-enable-unsafe-sort-pushdown={{.ENABLE_UNSAFE_SORT_PUSHDOWN}}

test-integration-mongodb:
desc: "Run integration tests for MongoDB"
Expand Down
14 changes: 8 additions & 6 deletions cmd/ferretdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ var cli struct {
Test struct {
RecordsDir string `default:"" help:"Testing: directory for record files."`

DisableFilterPushdown bool `default:"false" help:"Experimental: disable filter pushdown."`
EnableSortPushdown bool `default:"false" help:"Experimental: enable sort pushdown."`
EnableOplog bool `default:"false" help:"Experimental: enable capped collections, tailable cursors and OpLog." hidden:""`
DisableFilterPushdown bool `default:"false" help:"Experimental: disable filter pushdown."`
EnableSortPushdown bool `default:"false" help:"Experimental: enable sort pushdown."`
noisersup marked this conversation as resolved.
Show resolved Hide resolved
noisersup marked this conversation as resolved.
Show resolved Hide resolved
EnableUnsafeSortPushdown bool `default:"false" help:"Experimental: enable unsafe sort pushdown."`
EnableOplog bool `default:"false" help:"Experimental: enable capped collections, tailable cursors and OpLog." hidden:""`

//nolint:lll // for readability
Telemetry struct {
Expand Down Expand Up @@ -381,9 +382,10 @@ func run() {
HANAURL: hanaFlags.HANAURL,

TestOpts: registry.TestOpts{
DisableFilterPushdown: cli.Test.DisableFilterPushdown,
EnableSortPushdown: cli.Test.EnableSortPushdown,
EnableOplog: cli.Test.EnableOplog,
DisableFilterPushdown: cli.Test.DisableFilterPushdown,
EnableSortPushdown: cli.Test.EnableSortPushdown,
EnableUnsafeSortPushdown: cli.Test.EnableUnsafeSortPushdown,
EnableOplog: cli.Test.EnableOplog,
},
})
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@
HANAURL: *hanaURLF,

TestOpts: registry.TestOpts{
DisableFilterPushdown: *disableFilterPushdownF,
EnableSortPushdown: *enableSortPushdownF,
EnableOplog: true,
DisableFilterPushdown: *disableFilterPushdownF,
EnableSortPushdown: *enableSortPushdownF,
EnableUnsafeSortPushdown: *enableUnsafeSortPushdownF,
EnableOplog: true,
},
}
h, err := registry.NewHandler(handler, handlerOpts)
Expand All @@ -184,6 +185,10 @@
tb.Fatal("Both -target-tls and -target-unix-socket are set.")
}

if *enableSortPushdownF && *enableUnsafeSortPushdownF {
tb.Fatal("Both -enable-sort-pushdown and -enable-unsafe-sort-pushdown are set.")
}

Check warning on line 190 in integration/setup/listener.go

View check run for this annotation

Codecov / codecov/patch

integration/setup/listener.go#L189-L190

Added lines #L189 - L190 were not covered by tests

switch {
case *targetTLSF:
listenerOpts.TLS = "127.0.0.1:0"
Expand Down
5 changes: 3 additions & 2 deletions integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ var (
debugSetupF = flag.Bool("debug-setup", false, "enable debug logs for tests setup")
logLevelF = zap.LevelFlag("log-level", zap.DebugLevel, "log level for tests")

disableFilterPushdownF = flag.Bool("disable-filter-pushdown", false, "disable filter pushdown")
enableSortPushdownF = flag.Bool("enable-sort-pushdown", false, "enable sort pushdown")
disableFilterPushdownF = flag.Bool("disable-filter-pushdown", false, "disable filter pushdown")
enableSortPushdownF = flag.Bool("enable-sort-pushdown", false, "enable sort pushdown")
enableUnsafeSortPushdownF = flag.Bool("enable-unsafe-sort-pushdown", false, "enable unsafe sort pushdown")
)

// Other globals.
Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/registry/hana.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
ConnMetrics: opts.ConnMetrics,
StateProvider: opts.StateProvider,

DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,
EnableOplog: opts.EnableOplog,
DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,

Check warning on line 38 in internal/handlers/registry/hana.go

View check run for this annotation

Codecov / codecov/patch

internal/handlers/registry/hana.go#L38

Added line #L38 was not covered by tests
EnableUnsafeSortPushdown: opts.EnableUnsafeSortPushdown,
EnableOplog: opts.EnableOplog,
}

return sqlite.New(handlerOpts)
Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/registry/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ func init() {
ConnMetrics: opts.ConnMetrics,
StateProvider: opts.StateProvider,

DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,
EnableOplog: opts.EnableOplog,
DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,
EnableUnsafeSortPushdown: opts.EnableUnsafeSortPushdown,
EnableOplog: opts.EnableOplog,
}

return sqlite.New(handlerOpts)
Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ type NewHandlerOpts struct {

// TestOpts represents experimental configuration options.
type TestOpts struct {
DisableFilterPushdown bool
EnableSortPushdown bool
EnableOplog bool
DisableFilterPushdown bool
EnableSortPushdown bool
EnableUnsafeSortPushdown bool
EnableOplog bool
}

// NewHandler constructs a new handler.
Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/registry/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ func init() {
ConnMetrics: opts.ConnMetrics,
StateProvider: opts.StateProvider,

DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,
EnableOplog: opts.EnableOplog,
DisableFilterPushdown: opts.DisableFilterPushdown,
EnableSortPushdown: opts.EnableSortPushdown,
EnableUnsafeSortPushdown: opts.EnableUnsafeSortPushdown,
EnableOplog: opts.EnableOplog,
}

return sqlite.New(handlerOpts)
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/sqlite/msg_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (h *Handler) MsgAggregate(ctx context.Context, msg *wire.OpMsg) (*wire.OpMs
}

// Skip sorting if there are more than one sort parameters
if h.EnableSortPushdown && sort.Len() == 1 {
if h.EnableUnsafeSortPushdown && sort.Len() == 1 {
var order types.SortType

k := sort.Keys()[0]
Expand Down
6 changes: 3 additions & 3 deletions internal/handlers/sqlite/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
}

// Skip sorting if there are more than one sort parameters
if h.EnableSortPushdown && params.Sort.Len() == 1 {
if (h.EnableSortPushdown || h.EnableUnsafeSortPushdown) && params.Sort.Len() == 1 {
var order types.SortType

k := params.Sort.Keys()[0]
Expand All @@ -107,10 +107,10 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,

// Limit pushdown is not applied if:
// - `filter` is set, it must fetch all documents to filter them in memory;
// - `sort` is set but `EnableSortPushdown` is not set, it must fetch all documents
// - `sort` is set but `EnableUnsafeSortPushdown` is not set, it must fetch all documents
// and sort them in memory;
// - `skip` is non-zero value, skip pushdown is not supported yet.
if params.Filter.Len() == 0 && (params.Sort.Len() == 0 || h.EnableSortPushdown) && params.Skip == 0 {
if params.Filter.Len() == 0 && (params.Sort.Len() == 0 || h.EnableUnsafeSortPushdown) && params.Skip == 0 {
qp.Limit = params.Limit
}

Expand Down
6 changes: 3 additions & 3 deletions internal/handlers/sqlite/msg_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er
}

// Skip sorting if there are more than one sort parameters
if h.EnableSortPushdown && params.Sort.Len() == 1 {
if (h.EnableSortPushdown || h.EnableUnsafeSortPushdown) && params.Sort.Len() == 1 {
var order types.SortType

k := params.Sort.Keys()[0]
Expand All @@ -132,10 +132,10 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er

// Limit pushdown is not applied if:
// - `filter` is set, it must fetch all documents to filter them in memory;
// - `sort` is set but `EnableSortPushdown` is not set, it must fetch all documents
// - `sort` is set but `EnableUnsafeSortPushdown` is not set, it must fetch all documents
// and sort them in memory;
// - `skip` is non-zero value, skip pushdown is not supported yet.
if params.Filter.Len() == 0 && (params.Sort.Len() == 0 || h.EnableSortPushdown) && params.Skip == 0 {
if params.Filter.Len() == 0 && (params.Sort.Len() == 0 || h.EnableUnsafeSortPushdown) && params.Skip == 0 {
qp.Limit = params.Limit
}

Expand Down
7 changes: 4 additions & 3 deletions internal/handlers/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ type NewOpts struct {
StateProvider *state.Provider

// test options
DisableFilterPushdown bool
EnableSortPushdown bool
EnableOplog bool
DisableFilterPushdown bool
EnableSortPushdown bool
EnableUnsafeSortPushdown bool
EnableOplog bool
}

// New returns a new handler.
Expand Down
Loading