Commit Graph

762 Commits

Author SHA1 Message Date
Avi Kivity
e3de30f943 tools: toolchain: update frozen toolchain for python driver 3.26.7
Fixes scylladb/scylladb#16709
Fixes scylladb/scylladb#17353

Closes scylladb/scylladb#17604
2024-03-03 16:36:14 +02:00
Kefu Chai
010fb5f323 tools/scylla-nodetool: make keyspace argument optional for "ring"
the "keyspace" argument of the "ring" command is optional. but before
this change, we considered it a mandatory option. it was wrong.

so, in this change, we make it optional, and print out the warning
message if the keyspace is not specified.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17472
2024-02-23 09:25:29 +02:00
Botond Dénes
a08d9ba2a4 Merge 'tools/scylla-nodetool: fixes to address test failures with dtest' from Kefu Chai
* tighten the param check for toppartitions
* add an extra empty line inbetween reports

Closes scylladb/scylladb#17486

* github.com:scylladb/scylladb:
  tools/scylla-nodetool: add an extra empty line inbetween reports
  tools/scylla-nodetool: tighten the param check for toppartitions
2024-02-23 09:05:30 +02:00
Botond Dénes
234aa99aaa Merge 'tools/scylla-nodetool: extract and use {yaml,json}_writers' from Kefu Chai
simpler this way.

Closes scylladb/scylladb#17437

* github.com:scylladb/scylladb:
  tools/scylla-nodetool: use {yaml,json}_writers in compactionhistory_operation
  tools/scylla-nodetool: add {json,yaml}_writer
2024-02-23 08:13:07 +02:00
Kefu Chai
67c69be3c6 tools/scylla-nodetool: add an extra empty line inbetween reports
before this change, `toppartitions` does not print an empty line
after an empty sampling warning message. but
dtest/toppartitions_test.py actually split sampling reports with
two newlines, so let's appease it. the output also looks better
this way, as the samplings for READS and WRITES are always visually
separated with an empty line.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-23 12:57:51 +08:00
Kefu Chai
381c389b56 tools/scylla-nodetool: tighten the param check for toppartitions
the test cases of `test_any_of_required_parameters_is_missing`
considers that we should either pass all positional argument or
pass none of them, otherwise nodetool should fail. but `scylla nodetool`
supported partial positional argument.

to be more consistent with the expected behavior, in this change,
we enforce the sanity check so that we only accept either all
positional args or none of them. the corresponding test is added.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-23 12:57:51 +08:00
Kefu Chai
4ee2aee279 tools/scylla-nodetool: define operator<< for vector<sstring>
we already have generic operator<< based formatter for sequence-alike
ranges defined in `utils/to_string.hh`, but as a part of efforts to
address #13245, we will eventually drop the formatter.

to prepare for this change, we should create/find the alternatives
where the operator<< for printing the ranges is still used.
Boost::program_options is one of them. it prints the options' default
values using operator<< in its error message or usage. so in order
to keep it working, we define operator<< for `vector<sstring>` here.
if there are more types are required, we will need the generalize
this formatter. if there are more needs from different compiling
units, we might need to extract this helper into, for instance,
`utils/to_string.hh`. but we should do this after removing it.

Refs #13245

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17413
2024-02-22 09:01:04 +02:00
Kefu Chai
da7ffd4e73 tools/scylla-types: print using managed_bytes
instead of materializing the `managed_bytes_view` to a string, and
print it, print it directly to stdout. this change helps to deprecate
`to_hex()` helpers, we should materialize string only when necessary.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17463
2024-02-22 09:00:38 +02:00
Botond Dénes
94dac43b2f tools/utils: configure tools to use the epoll reactor backend
The default AIO backend requires AIO blocks. On production systems, all
available AIO blocks could have been already taken by ScyllaDB. Even
though the tools only require a single unit, we have seen cases where
not even that is available, ScyllDB having siphoned all of the available
blocks.
We could try to ensure all deployments have some spare blocks, but it is
just less friction to not have to deal with this problem at all, by just
using the epoll backend. We don't care about performance in the case of
the tools anyway, so long as they are not unreasonably slow. And since
these tools are replacing legacy tools written in Java, the bar is low.

Closes scylladb/scylladb#17438
2024-02-21 11:58:09 +02:00
Kefu Chai
61308d51ef tools/scylla-nodetool: use {yaml,json}_writers in compactionhistory_operation
simpler this way.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-21 16:49:30 +08:00
Kefu Chai
e9e558534a tools/scylla-nodetool: add {json,yaml}_writer
so that we have less repeatings for dumping the metrics. the repeatings
are error-prone and not maintainable. also move them out into a separate
header, to keep fit of this source file -- it's now 3000 LOC. also,
by moving them out, we can reuse them in other subcommands without
moving them to the top of this source file.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-21 16:49:30 +08:00
Kefu Chai
c627d9134e tools/scylla-nodetool: implement tablestats
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-20 18:12:35 +08:00
Kefu Chai
64f9d90f7b tools/scylla-nodetool: implement toppartitions
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17357
2024-02-20 08:16:43 +02:00
Kefu Chai
47ec74ad1a tools/scylla-nodetool: implement ring
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17375
2024-02-19 09:30:01 +02:00
Avi Kivity
d257cc5003 Merge 'scylla-nodetool: implement the repair command' from Botond Dénes
As usual, the new command is covered with tests, which pass with both the legacy and the new native implementation.

Refs: #15588

Closes scylladb/scylladb#17368

* github.com:scylladb/scylladb:
  tools/scylla-nodetool: implement the repair command
  test/nodetool: utils: add check_nodetool_fails_with_error_contains()
  test/nodetool: util: replace flags with custom matcher
2024-02-18 19:21:54 +02:00
Botond Dénes
b11213e547 tools/scylla-nodetool: implement the upgradesstables command
Refs: #15588

Closes scylladb/scylladb#17370
2024-02-18 19:21:53 +02:00
Kefu Chai
47fec0428a tools/scylla-nodetool: return 1 when viewbuild not succeeds
this change introduces a new exception which carries the status code
so that an operation can return a non-zero exit code without printing
any errors. this mimics the behavior of "viewbuildstatus" command of
C* nodetool.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17359
2024-02-16 13:53:33 +02:00
Botond Dénes
8d8ea12862 tools/scylla-nodetool: implement the repair command 2024-02-16 04:42:08 -05:00
Botond Dénes
22a5112bf1 tools/scylla-sstable-scripts: add keys.lua and largest-key.lua
I wrote these scripts to identify sstables with too large keys for a
recent investigation. I think they could be useful in the future,
certainly as further examples on how to write lua scripts for
scylla-sstable script.

Closes scylladb/scylladb#17000
2024-02-15 13:39:41 +02:00
Botond Dénes
811e931b09 Merge 'tools/scylla-nodetool: implement compactionstats and viewbuildstatus' from Kefu Chai
Refs #15588

Closes scylladb/scylladb#17344

* github.com:scylladb/scylladb:
  tools/scylla-nodetool: implement viewbuildstatus
  tools/scylla-nodetool: implement compactionstats
2024-02-15 12:44:05 +02:00
Kefu Chai
f9d19a61ff tools/scylla-nodetool: implement viewbuildstatus
Refs 15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-15 16:54:16 +08:00
Kefu Chai
68795eb8fa tools/scylla-nodetool: implement gossipinfo
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17317
2024-02-15 08:41:39 +02:00
Kefu Chai
a7abaa457b tools/scylla-nodetool: implement compactionstats
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-15 12:29:10 +08:00
Kefu Chai
d43c418f72 tools/scylla-nodetool: implement getendpoints
Refs #15588

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17332
2024-02-14 11:20:52 +02:00
Yaniv Kaul
d2ef100b60 Typos: more/less then -> more/less than
Fix repated typos in comments: more then -> more than, less then -> less than

Signed-off-by: Yaniv Kaul <yaniv.kaul@scylladb.com>

Closes scylladb/scylladb#17303
2024-02-13 17:16:15 +02:00
Avi Kivity
b22db74e6a Regenerate frozen toolchain
For gnutls 3.8.3 and clang clang-16.0.6-4.

Fixes #17285.

Closes scylladb/scylladb#17287
2024-02-12 18:36:11 +02:00
Kefu Chai
f990ea9678 tools/scylla-nodetool: implement describecluster
Refs #15588
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#17240
2024-02-11 20:21:07 +02:00
Botond Dénes
ba89b86913 Update tools/java submodule
* tools/java c75ce2c1...5e11ed17 (1):
  > bin/nodetool-wrapper: pass all args to nodetool for testings its ability
2024-02-09 16:34:47 +01:00
Botond Dénes
8fcb4ed707 tools/scylla-nodetool: implement describering
Also implementing tablet support, which basically just means that a new
table parameter is also accepted and forwarded to the API, in addition
to the existing keyspace one.
2024-02-08 09:20:25 -05:00
Botond Dénes
2df2733ed1 tools/scylla-nodetool.cc: handle API request failures gracefully
Currently, error handling is done via catching
http::unexpected_status_error and re-throwing an std::runtime_error.
Turns out this no longer works, because this error will only be thrown
by the http client, if the request had an expected reply code set.
The scylla_rest_client doesn't set an expected reply code, so this
exception was never thrown for some time now.
Furthermore, even when the above worked, it was not too user-friendly as
the error message only included the reply-code, but not the reply
itself.

So in this patch this is fixed:
* The handling of http::unexpected_status_error is removed, we don't
  want to use this mechanism, because it yields very terse error
  messages.
* Instead, the status code of the request is checked explicitely and all
  cases where it is not 200 are handled.
* A new api_request_failed exception is added, which is throw for all
  non-200 statuses with the extracted error message from the server (if
  any).
* This exception is caught by main, the error message is printed and
  scylla-nodetool returns with a new distinct error-code: 4.

With this, all cases where the request fails on ScyllaDB are handled and
we shouldn't hit cases where a nodetool command fails with some
obscure JSON parsing error, because the error reply has different JSON
schema than the expected happy-path reply.
2024-02-08 09:20:25 -05:00
Avi Kivity
784c2f8ad2 Merge 'treewide: replace calls to future::get0() by calls to future::get()' from Kefu Chai
get0() dates back from the days where Seastar futures carried tuples, and get0() was a way to get the first (and usually only) element. Now it's a distraction, and Seastar is likely to deprecate and remove it.

Replace with seastar::future::get(), which does the same thing.

Closes scylladb/scylladb#17130

* github.com:scylladb/scylladb:
  treewide: replace seastar::future::get0() with seastar::future::get()
  sstable: capture return value of get0() using auto
  utils: result_loop: define result_type with decayed type

[avi: add another one that snuck in while this was cooking]
2024-02-04 15:23:33 +02:00
Botond Dénes
017a574b16 tools: lua_sstable_consumer.cc: load os and math libs
The amount of standard Lua libraries loaded for the sstable-script was
limited, due to fears that some libraries (like the io library) could
expose methods, which if used from the script could interfere with
seastar's asynchronous arhitecture. So initially only the table and
string libraries were loaded.
This patch adds two more libraries to be loaded: match and os. The
former is self-explanatory and the latter contains methods to work with
date/time, obtain the values of environment variables as well as launch
external processes. None of these should interfere with seastar, on the
other hand the facilities they provide can come very handy for sstable
scripts.

Closes scylladb/scylladb#17126
2024-02-02 19:00:57 +03:00
Avi Kivity
7cb1c10fed treewide: replace seastar::future::get0() with seastar::future::get()
get0() dates back from the days where Seastar futures carried tuples, and
get0() was a way to get the first (and usually only) element. Now
it's a distraction, and Seastar is likely to deprecate and remove it.

Replace with seastar::future::get(), which does the same thing.
2024-02-02 22:12:57 +08:00
Kefu Chai
5e0b3671d3 storage_service: fall back to local cleanup in cleanup_all
before this change, if no keyspaces are specified,
scylla-nodetool just enumerate all non-local keyspaces, and
call "/storage_service/keyspace_cleanup" on them one after another.
this is not quite efficient, as each this RESTful API call
force a new active commitlog segment, and flushes all tables.
so, if the target node of this command has N non-local keyspaces,
it would repeat the steps above for N times. this is not necessary.
and after a topology change, we would like to run a global
"nodetool cleanup" without specifying the keyspace, so this
is a typical use case which we do care about.

to address this performance issue, in this change, we improve
an existing RESTful API call "/storage_service/cleanup_all", so
if the topology coordinator is not enabled, we fall back to
a local cleanup to cleanup all non-local keyspaces.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
2024-02-01 11:25:53 +08:00
Pavel Emelyanov
7c5c89ba8d Revert "Merge 'Use utils::directories instead of db::config to get dirs' from Patryk Wróbel"
This reverts commit 370fbd346c, reversing
changes made to 0912d2a2c6.

This makes scylla-manager mis-interpret the data_file_directories
somehow, issue #17078
2024-01-31 15:08:14 +03:00
Patryk Wrobel
51fa108df7 tools/scylla-sstable.cc: use utils::directories to get paths
This change replaces usage of db::config with usage
of utils::directories to get paths of directories
in tools/scylla-sstable.cc.

Refs: scylladb#5626
Signed-off-by: Patryk Wrobel <patryk.wrobel@scylladb.com>
2024-01-29 13:11:33 +01:00
Kefu Chai
f96d25a0a7 tool: check for existence of keyspace before getting it
in general, user should save output of `DESC foo.bar` to a file,
and pass the path to the file as the argument of `--schema-file`
option of `scylla sstable` commands. the CQL statement generated
from `DESC` command always include the keyspace name of the table.
but in case user create the CQL statement manually and misses
the keyspace name. he/she would have following assertion failure
```
scylla: cql3/statements/cf_statement.cc:49: virtual const sstring &cql3::statements::raw::cf_statement::keyspace() const: Assertion `_cf_name->has_keyspace()' failed.
```
this is not a great user experience.

so, in this change, we check for the existence of keyspace before
looking it up. and throw a runtime error with a better error mesage.
so when the CQL statement does not have the keyspace name, the new
error message would look like:
```
error processing arguments: could not load schema via schema-file: std::runtime_error (tools::do_load_schemas(): CQL statement does not have keyspace specified)
```

since this check is only performed by `do_load_schemas()` which
care about the existence of keyspace, and it only expects the
CQL statement to create table/keyspace/type, we just override the
new `has_keyspace()` method of the corresponding types derived
from `cf_statement`.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16981
2024-01-29 09:02:01 +02:00
Nadav Har'El
69a68e35dd Merge 'scylla-sstable: add support for loading schema of views and indexes' from Botond Dénes
Loading schemas of views and indexes was not supported, with either `--schema-file`, or when loading schema from schema sstables.
This PR addresses both:
* When loading schema from CQL (file), `CREATE MATERIALIZED VIEW` and `CREATE INDEX` statements are now also processed correctly.
* When loading schema from schema tables, `system_schema.views` is also processed, when the table has no corresponding entry in `system_schema.tables`.

Tests are also added.

Fixes: #16492

Closes scylladb/scylladb#16517

* github.com:scylladb/scylladb:
  test/cql-pytest: test_tools.py: add schema-loading tests for MV/SI
  test/cql-pytest: test_tools.py: extract some fixture logic to functions
  test/cql-pytest: test_tools.py: extract common schema-loading facilities into base-class
  tools/schema_loader: load_schema_from_schema_tables(): add support for MV/SI schemas
  tools/schema_loader: load_one_schema_from_file(): add support for view/index schemas
  test/boost/schema_loader_test: add test for mvs and indexes
  tools/schema_loader: load_schemas(): implement parsing views/indexes from CQL
  replica/database: extract existing_index_names and get_available_index_name
  tools/schema_loader: make real_db.tables the only source of truth on existing tables
  tools/schema_loader: table(): store const keyspace&
  tools/schema_loader: make database,keyspace,table non-movable
  cql3/statements/create_index_statement: build_index_schema(): include index metadata in returned value
  cql3/statements/create_index_statement: make build_index_schema() public
  cql3/statements/create_index_statement: relax some method's dependence on qp
  cql3/statements/create_view_statement: make prepare_view() public
2024-01-24 23:36:54 +02:00
Kefu Chai
8c39aba820 tools/scylla-sstable: use canonical path for sst_path
we deduce the paths to other SSTable components from the one
specified from the command line, for instance, if
/a/b/c/me-really-big-Data.db is fed to `scylla sstable`, the tool
would try to read /a/b/c/me-really-big-TOC.txt for the list of
other components. this works fine if the full path is specified
in the command line.

but if a relative path is specified, like, "me-really-big-Data.db",
this does not work anymore. before this change, the tool
would be reading "/me-really-big-TOC.txt", which does not exist
under most circumstances. while $PWD/me-really-big-TOC.txt should
exist if the SSTable is sane.

after this change, we always convert the specified path to
its canonical representation, no matter it is relative or absolutate.
this enables us to get the correct parent path path when trying
to read, for instance, the TOC component.

Fixes #16955
Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16964
2024-01-24 13:28:40 +02:00
Kamil Braun
cc039498c6 Update tools/cqlsh submodule
* tools/cqlsh 426fa0ea...b8d86b76 (8):
  > Make cqlsh work with unix domain sockets

Fixes scylladb/scylladb#16489

  > Bump python-driver version
  > dist/debian: add trailer line
  > dist/debian: wrap long line
  > Draft: explicit build-time packge dependencies
  > stop retruning status_code=2 on schema disagreement
  > Fix minor typos in the code
  > Dockerfile: apt-get update and apt-get upgrade to get latest OS packages
2024-01-19 11:23:22 +01:00
Avi Kivity
394ef13901 build: regenerate frozen toolchain for tablets-aware Python driver
Pull in scylla-driver 3.26.5, which supports tablets.

Closes scylladb/scylladb#16829
2024-01-17 22:47:36 +02:00
Pavel Emelyanov
267770bf0f cql3: Add feature service to get_keyspace_metadata()
To be passed down to ks_prop_defs::as_ks_metadata()

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2024-01-15 13:12:12 +03:00
Gleb Natapov
97ab3f6622 storage_service: topology_coordinator: introduce cleanup REST API integrated with the topology coordinator
Introduce new REST API "/storage_service/cleanup_all"
that, when triggered, instructs the topology coordinator to initiate
cluster wide cleanup on all dirty nodes. It is done by introducing new
global command "global_topology_request::cleanup".
2024-01-14 15:45:53 +02:00
Botond Dénes
b69f7126c3 Update tools/java submodule
* tools/java 24e51259...c75ce2c1 (1):
  > Update JNA dependency to 5.14.0
2024-01-12 09:47:20 +02:00
Botond Dénes
3d1667c720 Update ./tools/java submodule
* ./tools/java e106b500...24e51259 (1):
  > build.xml: update io.airlift to 0.9
2024-01-11 08:55:51 +02:00
Lakshmi Narayanan Sreethar
76f0d5e35b reader_permit: store schema_ptr instead of raw schema pointer
Store schema_ptr in reader permit instead of storing a const pointer to
schema to ensure that the schema doesn't get changed elsewhere when the
permit is holding on to it. Also update the constructors and all the
relevant callers to pass down schema_ptr instead of a raw pointer.

Fixes #16180

Signed-off-by: Lakshmi Narayanan Sreethar <lakshmi.sreethar@scylladb.com>

Closes scylladb/scylladb#16658
2024-01-11 08:37:56 +02:00
Botond Dénes
5981900dca Update tools/jmx submodule
* tools/jmx 80ce5996...3257897a (1):
  > scylla-apiclient: drop hk2-locator dependency
2024-01-10 08:53:20 +02:00
Kefu Chai
34b03867b2 tools: do not include unused headers
these unused includes were identified by clangd. see
https://clangd.llvm.org/guides/include-cleaner#unused-include-warning
for more details on the "Unused include" warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16673
2024-01-10 08:44:09 +02:00
Pavel Emelyanov
cdf5124003 Merge 'tools/scylla-sstable: pass error handler to utils::config_file::read_from_file()' from Botond Dénes
The default error handler throws an exception, which means scylla-sstable will exit with exception if there is any problem in the configuration. Not even ScyllaDB itself is this harsh -- it will just log a warning for most errors. A tool should be much more lenient. So this patch passes an error handler which just logs all errors with debug level.
If reading an sstable fails, the user is expected to investigate turning debug-level logging on. When they do so, they will see any problems while reading the configuration (if it is relevant, e.g. when using EAR).

Fixes: #16538

Closes scylladb/scylladb#16657

* github.com:scylladb/scylladb:
  tools/scylla-sstable: pass error handler to utils::config_file::read_from_file()
  tools/scylla-sstable: allow always passing --scylla-yaml-file option
2024-01-09 14:28:49 +03:00
Kefu Chai
a6152cb87b sstables: do not include unused headers
these unused includes were identified by clangd. see
https://clangd.llvm.org/guides/include-cleaner#unused-include-warning
for more details on the "Unused include" warning.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#16666
2024-01-09 11:45:44 +02:00