Skip to content

Instantly share code, notes, and snippets.

View mattlord's full-sized avatar
😶‍🌫️

Matt Lord mattlord

😶‍🌫️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mattlord on github.
  • I am mattlord (https://keybase.io/mattlord) on keybase.
  • I have a public key ASDp1c17IPsdzfAeAx5fBgeZfjSiXGLF1a1hR-Z9LeWZwQo

To claim this, I am signing this object:

# This is the demo that I walked through in this talk: https://www.slideshare.net/mattalord/using-mysql-containers
Let's look at our current Docker environment:
docker version
docker info
docker system df
# as you play around, I would recommend you run this once in a while: docker system prune && docker volume prune
docker stats
docker ps -a
docker network ls
@mattlord
mattlord / App.java
Last active December 13, 2018 15:31
Example Java Application Using the MongoDB Embedded Java Driver
package com.mongodb.iot_guestbook;
import com.mongodb.embedded.client.*;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Projections;
import com.mongodb.client.model.Sorts;
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.25 |
+-----------+
1 row in set (0.00 sec)
mysql> select "Hey! 🙂" = "Hey! 😡" collate utf8mb4_general_ci;
+------------------------------------------------+
The Pos column in the _vt.vreplication table is the vreplication equivalent of mysqld's @@global.gtid_executed value
The hard part is finding the source GTID you think you want to skip, verifying the contents of it and that it matches the error, and finally that it's safe to skip
You can find the source tablet for that errored vstream in the workflow output, e.g.:
...
{
"Shard": "-",
"Tablet": "us_central1_a-3612345650",
"ID": 16,
❯ echo "${RANDOM}:${RANDOM}:${RANDOM} -- cat beer mustang mountain noway -- you are the owner of Matt's art, congrats" > /tmp/nft-input.txt
❯ cat /tmp/nft-input.txt
4303:3459:12817 -- cat beer mustang mountain noway -- you are the owner of Matt's art, congrats
❯ shasum -a 256 /tmp/nft-input.txt | awk '{print $1}' > /tmp/mattsart-nft.txt
❯ cat /tmp/mattsart-nft.txt
3bcbd498e57d4bcd85abeeb79fb006f483801043517d555902939bd70c85f925
##
# Signed into https://app.planetscale.com using GitHub
##
# Install CLI
$ brew tap planetscale/tap
$ brew install pscale
$ pscale login

For VReplication streams, we must choose a tablet to serve the role of vstreamer (source) and vapplier (target) in the replication stream.

Key context for the tablet picker: cells, keyspace, shard, and tablet types (primary/master, replica).

ℹ️ VReplication will only look for tablet pairings within the same cell. If you want to have cross-cell streams then you will need to create a CellAlias that contains the list of potential cells and specify that using the -cell flag in your VReplication workflow commands.

The tablet picker logic for is here. It gets a set of valid candidates for the source and target of the stream:

  • Source (vstreamer): it uses the random ta
$ cat /tmp/sites.sql
CREATE TABLE sites(
  site_id bigint,
  name varchar(128),
  primary key(site_id)
);

$ cat /tmp/sites.vschema
{

Command

You pass vtcombo a combination of flags that you would normally pass to the individual components (vtgate, vtctld, vttablet). For example:

vtcombo -logtostderr=true -proto_topo "$(cat ./topology)" -schema_dir ./vschema -mysql_server_port 15306 -mysql_server_bind_address 0.0.0.0 -mysql_auth_server_impl none -db_socket /tmp/mysql.sock -db_host localhost -mycnf-file /etc/mysql/my.cnf -db_app_user root -db_allprivs_user root -db_appdebug_user root -db_dba_user root -db_repl_user root -dbddl_plugin vttest -port 15000 -grpc_port 15001 -service_map 'grpc-vtgateservice,grpc-vtctl,grpc-vtctld' -db_charset utf8mb4 -vschema_ddl_authorized_users='%'

Example Topology File (-proto_topo)

keyspaces {