Skip to content

Commit ee821ed

Browse files
committed
add Replicator security content; refine includes
1 parent bfabec1 commit ee821ed

12 files changed

+756
-316
lines changed

src/current/_includes/molt/fetch-secure-connection-strings.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/current/_includes/molt/molt-connection-strings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ For details, refer to [Connect using a URL]({% link {{site.current_cloud_version
7272

7373
#### Secure connections
7474

75-
{% include molt/fetch-secure-connection-strings.md %}
75+
{% include molt/molt-secure-connection-strings.md %}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
- To keep your database credentials out of shell history and logs, follow these best practices when specifying your source and target connection strings:
2+
3+
- Avoid plaintext connection strings.
4+
5+
- Provide your connection strings as environment variables. For example:
6+
7+
~~~ shell
8+
export SOURCE="postgres://migration_user:a%2452%26@localhost:5432/molt?sslmode=verify-full"
9+
export TARGET="postgres://root@localhost:26257/molt?sslmode=verify-full"
10+
~~~
11+
12+
Afterward, reference the environment variables in MOLT commands:
13+
14+
{% if page.name == "molt-replicator.md" %}
15+
~~~
16+
--sourceConn $SOURCE
17+
--targetConn $TARGET
18+
~~~
19+
{% else %}
20+
~~~
21+
--source $SOURCE
22+
--target $TARGET
23+
~~~
24+
{% endif %}
25+
26+
- If possible, use an external secrets manager to load the environment variables from stored secrets.
27+
28+
- Use TLS-enabled connection strings to encrypt data in transit from MOLT to the database. When using TLS certificates, ensure certificate files are accessible to the MOLT binary on the same machine.
29+
30+
For example, a PostgreSQL connection string with TLS certificates:
31+
32+
{% include_cached copy-clipboard.html %}
33+
~~~
34+
postgresql://[email protected]:5432/appdb?sslmode=verify-full&sslrootcert=/etc/molt/certs/ca.pem&sslcert=/etc/molt/certs/client.crt&sslkey=/etc/molt/certs/client.key
35+
~~~
36+
37+
- URL-encode connection strings for the source database and [CockroachDB]({% link {{site.current_cloud_version}}/connect-to-the-database.md %}) so special characters in passwords are handled correctly.
38+
39+
- Given a password `a$52&`, pass it to the `molt escape-password` command with single quotes:
40+
41+
{% include_cached copy-clipboard.html %}
42+
~~~ shell
43+
molt escape-password --password 'a$52&'
44+
~~~
45+
46+
Use the encoded password in your connection string. For example:
47+
48+
~~~
49+
postgres://migration_user:a%2452%26@localhost:5432/replicationload
50+
~~~
51+
52+
- Remove `sslmode=disable` from production connection strings.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
### Failback issues
2+
3+
If the changefeed shows connection errors in `SHOW CHANGEFEED JOB`:
4+
5+
##### Connection refused
6+
7+
~~~
8+
transient error: Post "https://replicator-host:30004/molt/public": dial tcp [::1]:30004: connect: connection refused
9+
~~~
10+
11+
This indicates that Replicator is down, the webhook URL is incorrect, or the port is misconfigured.
12+
13+
**Resolution:** Verify that MOLT Replicator is running on the port specified in the changefeed `INTO` configuration. Confirm the host and port are correct.
14+
15+
##### Unknown schema error
16+
17+
~~~
18+
transient error: 400 Bad Request: unknown schema:
19+
~~~
20+
21+
This indicates the webhook URL path is incorrectly formatted. Common causes include using the wrong path format for your target database type or incorrect database names.
22+
23+
**Resolution:** Check the webhook URL path mapping:
24+
25+
- **PostgreSQL targets:** Use `/database/schema` format (for example, `/molt_db/public`).
26+
- **MySQL/Oracle targets:** Use `/SCHEMA` format (for example, `/MOLT_DB`). Use only the schema name (for example, `molt` instead of `molt/public`).
27+
28+
Verify that the target database and schema names match the webhook URL.
29+
30+
##### GC threshold error
31+
32+
~~~
33+
batch timestamp * must be after replica GC threshold
34+
~~~
35+
36+
This indicates starting from an invalid cursor that has been garbage collected.
37+
38+
**Resolution:** Double-check the cursor to ensure it represents a valid range that has not been garbage collected, or extend the GC TTL on the source CockroachDB cluster:
39+
40+
{% include_cached copy-clipboard.html %}
41+
~~~ sql
42+
ALTER DATABASE defaultdb CONFIGURE ZONE USING gc.ttlseconds = {gc_ttl_in_seconds};
43+
~~~
44+
45+
##### Duplicated data re-application
46+
47+
This occurs when resuming a changefeed from a cursor causes excessive data duplication.
48+
49+
**Resolution:** Clear the staging database to prevent duplication. **This deletes all checkpoints and buffered data**, so use with caution:
50+
51+
{% include_cached copy-clipboard.html %}
52+
~~~ sql
53+
DROP DATABASE _replicator;
54+
~~~
55+
56+
For more targeted cleanup, delete mutations from specific staging tables:
57+
58+
{% include_cached copy-clipboard.html %}
59+
~~~ sql
60+
DELETE FROM _replicator.employees WHERE true;
61+
~~~
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
### Fetch issues
2+
3+
##### Fetch exits early due to mismatches
4+
5+
`molt fetch` exits early in the following cases, and will output a log with a corresponding `mismatch_tag` and `failable_mismatch` set to `true`:
6+
7+
- A source table is missing a primary key.
8+
- A source primary key and target primary key have mismatching types.
9+
- A [`STRING`]({% link {{site.current_cloud_version}}/string.md %}) primary key has a different [collation]({% link {{site.current_cloud_version}}/collate.md %}) on the source and target.
10+
- A source and target column have mismatching types that are not [allowable mappings]({% link molt/molt-fetch.md %}#type-mapping).
11+
- A target table is missing a column that is in the corresponding source table.
12+
- A source column is nullable, but the corresponding target column is not nullable (i.e., the constraint is more strict on the target).
13+
14+
`molt fetch` can continue in the following cases, and will output a log with a corresponding `mismatch_tag` and `failable_mismatch` set to `false`:
15+
16+
- A target table has a column that is not in the corresponding source table.
17+
- A source column has a `NOT NULL` constraint, and the corresponding target column is nullable (i.e., the constraint is less strict on the target).
18+
- A [`DEFAULT`]({% link {{site.current_cloud_version}}/default-value.md %}), [`CHECK`]({% link {{site.current_cloud_version}}/check.md %}), [`FOREIGN KEY`]({% link {{site.current_cloud_version}}/foreign-key.md %}), or [`UNIQUE`]({% link {{site.current_cloud_version}}/unique.md %}) constraint is specified on a target column and not on the source column.
19+
20+
<section class="filter-content" markdown="1" data-scope="oracle">
21+
##### ORA-01950: no privileges on tablespace
22+
23+
If you receive `ORA-01950: no privileges on tablespace 'USERS'`, it means the Oracle table owner (`migration_schema` in the preceding examples) does not have sufficient quota on the tablespace used to store its data. By default, this tablespace is `USERS`, but it can vary. To resolve this issue, grant a quota to the table owner. For example:
24+
25+
~~~ sql
26+
-- change UNLIMITED to a suitable limit for the table owner
27+
ALTER USER migration_schema QUOTA UNLIMITED ON USERS;
28+
~~~
29+
30+
##### No tables to drop and recreate on target
31+
32+
When expecting a bulk load but seeing `no tables to drop and recreate on the target`, ensure the migration user has `SELECT` and `FLASHBACK` privileges on each table to be migrated. For example:
33+
34+
~~~ sql
35+
GRANT SELECT, FLASHBACK ON migration_schema.employees TO C##MIGRATION_USER;
36+
GRANT SELECT, FLASHBACK ON migration_schema.payments TO C##MIGRATION_USER;
37+
GRANT SELECT, FLASHBACK ON migration_schema.orders TO C##MIGRATION_USER;
38+
~~~
39+
40+
##### Table or view does not exist
41+
42+
If the Oracle migration user lacks privileges on certain tables, you may receive errors stating that the table or view does not exist. Either use `--table-filter` to {% if page.name != "migrate-load-replicate.md" %}[limit the tables to be migrated]({% link molt/migrate-load-replicate.md %}#schema-and-table-filtering){% else %}[limit the tables to be migrated](#schema-and-table-filtering){% endif %}, or grant the migration user `SELECT` privileges on all objects in the schema. Refer to {% if page.name != "migrate-load-replicate.md" %}[Create migration user on source database]({% link molt/migrate-load-replicate.md %}#create-migration-user-on-source-database){% else %}[Create migration user on source database](#create-migration-user-on-source-database){% endif %}.
43+
44+
##### Oracle sessions remain open after forcefully stopping `molt` or `replicator`
45+
46+
If you shut down `molt` or `replicator` unexpectedly (e.g., with `kill -9` or a system crash), Oracle sessions opened by these tools may remain active.
47+
48+
- Check your operating system for any running `molt` or `replicator` processes and terminate them manually.
49+
- After confirming that both processes have stopped, ask a DBA to check for active Oracle sessions using:
50+
51+
~~~ sql
52+
SELECT sid, serial#, username, status, osuser, machine, program
53+
FROM v$session
54+
WHERE username = 'C##MIGRATION_USER';
55+
~~~
56+
57+
Wait until any remaining sessions display an `INACTIVE` status, then terminate them using:
58+
59+
~~~ sql
60+
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
61+
~~~
62+
63+
Replace `sid` and `serial#` in the preceding statement with the values returned by the `SELECT` query.
64+
</section>

0 commit comments

Comments
 (0)