Skip to content

Instantly share code, notes, and snippets.

View PeterCorless's full-sized avatar

Peter Corless PeterCorless

View GitHub Profile
@PeterCorless
PeterCorless / websocket_demo.cc
Created August 11, 2022 15:51
WebSocket in Seastar
ws.register_handler("echo", [] (input_stream<char>& in,
output_stream<char>& out) {
return repeat([&in, &out]() {
return in.read().then([&out](temporary_buffer<char> f) {
std::cerr << "f.size(): " << f.size() << "\n";
if (f.empty()) {
return make_ready_future<stop_iteration>(stop_iteration::yes);
} else {
return out.write(std::move(f)).then([&out]() {
return out.flush().then([] {
@PeterCorless
PeterCorless / alternator-slow-query-logging.txt
Created August 4, 2022 05:28
ScyllaDB Alternator Slow Query Logging
cqlsh> select parameters, duration from system_traces.node_slow_log where start_time=b7a44589-8711-11eb-8053-14c6c5faf955;
parameters | duration
---------------------------------------------------------------------------------------------+----------
{'alternator_op': 'DeleteTable', 'query': '{"TableName": "alternator_Test_1615979572905"}'} | 75732
[{
'start_time': 'b7d42b37-a661-11eb-a391-3d2009e69e44',
'node_ip': '127.0.0.1',
'shard': '0',
'command': '{"TableName": "Pets", "Key": {"p": {"S": "dog"}}}',
@PeterCorless
PeterCorless / 00-sctool-repair.txt
Last active June 7, 2022 18:05
ScyllaDB-Manager-3.0
sctool repair -K system* --name system_auth --dry-run --cron '1 2 3 4 5'
NOTICE: dry run mode, repair is not scheduled
Cron: 1 2 3 4 5 (At 02:01 AM, on day 3 of the month, and on Friday, only in April)
Tz: America/New_York
Data Centers:
- dc1
- dc2
@PeterCorless
PeterCorless / scylla-manager-2-5.sh
Last active August 30, 2021 18:04
Scylla Manager 2.5
sctool status -c test-cluster
Datacenter: eu-west
╭────┬────────────┬────────────┬──────────┬────────────────┬──────────┬──────┬──────────┬────────┬──────────┬──────────────────────────────────────╮
│    │ Alternator │ CQL        │ REST     │ Address        │ Uptime   │ CPUs │ Memory   │ Scylla │ Agent    │ Host ID                              │
├────┼────────────┼────────────┼──────────┼────────────────┼──────────┼──────┼──────────┼────────┼──────────┼──────────────────────────────────────┤
│ UN │ UP (12ms)  │ DOWN (0ms) │ UP (3ms) │ 192.168.100.11 │ 1h32m35s │ 4    │ 31.11GiB │ 4.2.1  │ 2.5.0    │ 1edbfd5b-4b1c-4bb0-afab-d69fd25db6af │
│ UN │ UP (8ms)   │ UP (3ms)   │ UP (5ms) │ 192.168.100.12 │ 1h32m35s │ 4    │ 31.11GiB │ 4.2.1  │ 2.5.0    │ 0c0999a2-c879-4e69-9924-1641c8487bd5 │
│ UN │ UP (10ms)  │ UP (8ms)   │ UP (1ms) │ 192.168.100.13 │ 1h32m35s │ 4    │ 31.11GiB │ 4.2.1  │ 2.5.0    │ 73e9818e-ed8d-4ea8-89e4-cf485dfd4ebe │
╰────┴────────────┴────────────┴──────────┴────────────────┴──────────┴──────┴─
@PeterCorless
PeterCorless / 01-sctool-status.sh
Last active June 30, 2021 18:38
Scylla-Manager-Cloning
$ sctool status
Cluster: test (77472fd3-a85f-4c8e-bdf5-6c17696ab975)
Datacenter: dc1
╭────┬────────────┬──────────┬──────────┬────────────────┬──────────┬──────┬──────────┬────────┬──────────┬──────────────────────────────────────╮
│ │ Alternator │ CQL │ REST │ Address │ Uptime │ CPUs │ Memory │ Scylla │ Agent │ Host ID │
├────┼────────────┼──────────┼──────────┼────────────────┼──────────┼──────┼──────────┼────────┼──────────┼──────────────────────────────────────┤
│ UN │ UP (13ms) │ UP (5ms) │ UP (2ms) │ 192.168.100.11 │ 7h26m34s │ 4 │ 31.12GiB │ 4.2.1 │ Snapshot │ 3827c1d1-b300-4093-9839-0cf01f1b9346 │
│ UN │ UP (9ms) │ UP (3ms) │ UP (2ms) │ 192.168.100.12 │ 7h26m34s │ 4 │ 31.12GiB │ 4.2.1 │ Snapshot │ a4f20c78-0a64-490c-b7f4-f52a62667ff8 │
│ UN │ UP (14ms) │ UP (4ms) │ UP (2ms) │ 192.168.100.13 │ 7h26m34s │ 4 │ 31.12GiB │ 4.2.1 │ Snapshot │ ffa39462-d3f1-46d9-875c-ef89044e951e │
╰────┴────────────┴──────────┴──────────┴────────────────
$ sctool suspend -c prod
$ sctool task list
Cluster: prod (097351fe-3c28-4f13-bbac-213981513968)
╭─────────────────────────────────────────────────────────────┬─────────────────┬───────────────────────────────────────────┬─────────╮
│ Task │ Arguments │ Next run │ Status │
├─────────────────────────────────────────────────────────────┼─────────────────┼───────────────────────────────────────────┼─────────┤
│ healthcheck/b657ed84-0451-4c0c-ac4c-dacd704c1ff7 │ │ 29 Mar 21 13:39:05 CEST (+15s) │ DONE │
│ healthcheck_alternator/7046049b-6ea8-4a58-9d60-c6c241354681 │ │ 29 Mar 21 13:39:05 CEST (+15s) │ DONE │
│ healthcheck_rest/0303dda3-f417-4997-8d81-6a4936d6be56 │ │ 29 Mar 21 13:39:20 CEST (+1m) │ DONE │
│ repair/7ddaa89e-d6ae-4292-8d6b-1ab8fa13d39b │ │ [SUSPENDED] 30 Mar 21 00:00:0
@PeterCorless
PeterCorless / 01-try-cluster.java
Last active February 9, 2021 00:20
Reading CDC with Java and Go
try (Cluster cluster = Cluster.builder().addContactPoint(source).build();
Session session = cluster.connect()) {
cqlsh> SELECT * from system.status;
peer | dc | host_id | load | owns | status | tokens | up
-----------+-------------+--------------------------------------+-------------+------+--------+--------+------
127.0.0.1 | datacenter1 | cf58dfca-c221-4b4a-a67a-414d4be5bb33 | 1.18745e+08 | 1 | NORMAL | 256 | True
@PeterCorless
PeterCorless / sctool-repair.sh
Created November 12, 2020 18:03
Scylla Manager 2.2 Repair Revisited
Status: DONE
Start time: 12 Nov 20 13:17:26 CET
End time: 12 Nov 20 13:21:11 CET
Duration: 3m45s
Progress: 100%
Datacenters:
- dc1
- dc2
 
╭───────────────┬────────┬──────────┬──────────╮
@PeterCorless
PeterCorless / 01-sctool-task-list.sh
Created July 7, 2020 17:12
Scylla Manager 2.0 Backups
> sctool task list Cluster: cluster1 (7313fda0-6ebd-4513-8af0-67ac8e30077b)
╭───────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────┬───────────────────────────────┬─────────╮
│ Task │ Arguments │ Next run │ Status │
├───────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┼───────────────────────────────┼─────────┤
│ healthcheck/ba29df86-6f31-4984-a2ba-a3855290f00d │ │ 12 May 20 13:15:47 UTC (+15s) │ DONE │
│ healthcheck_rest/dcb6cd6a-f66c-4493-824d-43599dc83519 │ │ 12 May 20 14:08:47 UTC (+1h) │ DONE │
│ backup/001ce624-9ac2-4076-a502-ec99d01effe4 │ -L s3:backup-bucket --retention 7 --rate-limit 50 │ 13 May 20 13:15:18 UTC (