rustberg 0.0.5

A production-grade, cross-platform, single-binary Apache Iceberg REST Catalog
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
---
layout: default
title: Troubleshooting
nav_order: 11
description: "Troubleshooting guide for common Rustberg issues"
permalink: /docs/troubleshooting
---

# Troubleshooting
{: .no_toc }

Solutions for common issues and debugging techniques.
{: .fs-6 .fw-300 }

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

---

## Startup Issues

### macOS: "Cannot Be Opened" or "Unverified Developer"

**Symptom:** macOS blocks the binary with a security warning when trying to run it.

```
"rustberg-darwin-aarch64" cannot be opened because the developer cannot be verified.
```

**Solution:** Remove the quarantine attribute from the downloaded binary:

```bash
# Remove quarantine attribute
xattr -cr ./rustberg-darwin-aarch64

# Make executable
chmod +x ./rustberg-darwin-aarch64

# Now run it
./rustberg-darwin-aarch64
```

{: .note }
> This is required because the binary was downloaded from the internet and macOS Gatekeeper quarantines it by default.

### Server Won't Start

**Symptom:** Server exits immediately after starting.

**Check 1: Port already in use**

```bash
# Find process using port
lsof -i :8181

# Use different port
./rustberg --port 8182
```

**Check 2: Storage permissions**

```bash
# Local storage
ls -la /var/lib/rustberg
chmod 700 /var/lib/rustberg

# S3 permissions
aws sts get-caller-identity
aws s3 ls s3://my-bucket/
```

**Check 3: Config file syntax**

```bash
# Validate TOML
./rustberg --config config.toml 2>&1 | head -20
```

### CORS Origin Not Allowed

**Symptom:** Server exits with "CORS allows all origins" error.

```
❌ CORS allows all origins ("*") - not allowed in production
   Configure server.cors.allowed_origins in your config file
```

**Solution 1: Configure explicit CORS origins in config.toml**

```toml
[server.cors]
allowed_origins = ["https://your-app.example.com"]
```

**Solution 2: Use development mode for local testing**

```bash
# For local development only
./rustberg --dev --insecure-http
```

{: .warning }
> Never use `--dev` in production. Always configure explicit CORS origins.

### TLS Certificate Errors

**Symptom:** `error: failed to load TLS certificate`

```bash
# Check certificate validity
openssl x509 -in cert.pem -text -noout

# Check key matches certificate
openssl x509 -noout -modulus -in cert.pem | openssl md5
openssl rsa -noout -modulus -in key.pem | openssl md5
# Both should match

# Generate new self-signed cert
./rustberg generate-cert --common-name localhost
```

---

## Authentication Issues

### 401 Unauthorized

**Symptom:** All requests return 401.

**Check 1: API key format**

```bash
# Correct format
curl -H "Authorization: Bearer rustberg_xxxxx" \
     http://localhost:8181/v1/config

# Common mistakes:
# ❌ curl -H "Authorization: rustberg_xxxxx"  # Missing "Bearer"
# ❌ curl -H "Bearer rustberg_xxxxx"          # Missing "Authorization:"
# ❌ curl -H "Authorization: Bearer  rustberg_xxxxx"  # Extra space
```

**Check 2: API key validity**

```bash
# Check if key was rotated or expired
# Verify in audit logs
grep "auth_failure" /var/log/rustberg/audit.log | tail -10
```

**Check 3: JWT configuration**

```bash
# Test JWKS endpoint
curl https://auth.example.com/.well-known/jwks.json | jq

# Decode JWT to check claims
echo 'eyJhbGc...' | cut -d. -f2 | base64 -d | jq

# Verify issuer and audience match config
```

### 403 Forbidden

**Symptom:** Authentication succeeds but authorization fails.

**Check 1: Cedar policy**

```bash
# Test policy with cedar CLI
cedar evaluate \
  --policies /etc/rustberg/policies/catalog.cedar \
  --principal 'User::"user@example.com"' \
  --action 'Action::"read"' \
  --resource 'Table::"analytics.events"'
```

**Check 2: Tenant isolation**

```bash
# Verify tenant_id in JWT/API key matches resource
# Check audit log for specific denial reason
grep "authz_deny" /var/log/rustberg/audit.log | tail -10 | jq
```

**Check 3: Role assignment**

```bash
# Verify user has correct roles
# Check API key metadata or JWT claims
```

---

## Storage Issues

### Local Filesystem Errors

**Symptom:** `read-only filesystem or storage medium` error when using `file://` warehouse.

```
opendal::layers::retry: will retry after 2s because: Unexpected (temporary) at write, 
context: { service: fs, path: warehouse/... } => read-only filesystem or storage medium, 
source: Read-only file system (os error 30)
```

**Cause:** The warehouse directory doesn't exist or the path is malformed.

**Solution:** Rustberg automatically creates local directories and supports relative paths:

```bash
# Relative path (creates ./warehouse in current directory)
./rustberg --warehouse file://warehouse

# Absolute path
./rustberg --warehouse file:///var/lib/rustberg/warehouse

# Bare relative path also works
./rustberg --warehouse warehouse
```

{: .note }
> Rustberg automatically converts relative paths to absolute paths and creates the directory if it doesn't exist.

**Check directory permissions:**

```bash
# Verify the resolved path
ls -la $(pwd)/warehouse

# If permission denied, fix ownership
sudo chown -R $(whoami) /path/to/warehouse
```

### S3 Access Denied

**Symptom:** `AccessDenied` errors when accessing S3.

```bash
# Verify credentials
aws sts get-caller-identity

# Test bucket access
aws s3 ls s3://my-bucket/rustberg-catalog/

# Check bucket policy
aws s3api get-bucket-policy --bucket my-bucket

# Verify IAM permissions
aws iam get-user-policy --user-name myuser --policy-name rustberg
```

### GCS Permission Denied

**Symptom:** `403 Forbidden` when accessing GCS.

```bash
# Verify service account
gcloud auth list

# Test bucket access
gsutil ls gs://my-bucket/rustberg-catalog/

# Check IAM binding
gsutil iam get gs://my-bucket
```

### Azure Blob Access Denied

**Symptom:** `AuthorizationFailure` when accessing Azure.

```bash
# Verify credentials
az account show

# Test container access
az storage blob list \
  --account-name mystorageaccount \
  --container-name mycontainer

# Check RBAC assignment
az role assignment list --assignee <service-principal-id>
```

### Local Storage Full

**Symptom:** `No space left on device`

```bash
# Check disk usage
df -h /var/lib/rustberg

# Clean old data (if safe)
du -sh /var/lib/rustberg/*

# Consider moving to larger disk or cloud storage
```

---

## Catalog Issues

### Table Not Found

**Symptom:** `NoSuchTableException` for existing table.

**Check 1: Correct namespace**

```bash
# List namespaces
curl -H "Authorization: Bearer $API_KEY" \
     http://localhost:8181/v1/namespaces | jq

# List tables in namespace
curl -H "Authorization: Bearer $API_KEY" \
     http://localhost:8181/v1/namespaces/my_namespace/tables | jq
```

**Check 2: Tenant isolation**

```bash
# Ensure API key has correct tenant_id
# Tables are isolated by tenant
```

### Commit Conflict

**Symptom:** `CommitFailedException` on table update.

This is normal behavior with optimistic concurrency. Solutions:

1. **Retry with backoff:**
   ```python
   from tenacity import retry, stop_after_attempt, wait_exponential

   @retry(stop=stop_after_attempt(3), wait=wait_exponential())
   def update_table():
       # Your update code
   ```

2. **Check for concurrent writers:**
   - Multiple processes updating same table
   - Consider serializing updates

### Namespace Already Exists

**Symptom:** `AlreadyExistsException` when creating namespace.

```bash
# Check if namespace exists
curl -H "Authorization: Bearer $API_KEY" \
     http://localhost:8181/v1/namespaces/my_namespace | jq

# If exists, use it or choose different name
```

---

## Performance Issues

### High Latency

**Symptom:** Requests take longer than expected.

**Check 1: Network latency**

```bash
# Test from client to server
curl -w "@curl-format.txt" -o /dev/null -s \
     http://localhost:8181/health

# curl-format.txt:
# time_namelookup:  %{time_namelookup}s\n
# time_connect:     %{time_connect}s\n
# time_appconnect:  %{time_appconnect}s\n
# time_total:       %{time_total}s\n
```

**Check 2: Storage backend latency**

```bash
# S3 latency
aws s3api head-object \
  --bucket my-bucket \
  --key rustberg-catalog/test
```

**Check 3: Rate limiting**

```bash
# Check for rate limit headers
curl -i -H "Authorization: Bearer $API_KEY" \
     http://localhost:8181/v1/config | grep -i ratelimit
```

### Memory Usage High

**Symptom:** Memory usage exceeds expected ~9MB.

```bash
# Check actual usage
ps aux | grep rustberg

# Check for memory leaks
# Monitor over time
watch -n 5 'ps aux | grep rustberg'
```

Possible causes:
- Large number of cached DEKs (encryption)
- Many concurrent connections
- Large request bodies

---

## KMS Issues

### AWS KMS Access Denied

```bash
# Verify KMS permissions
aws kms describe-key --key-id <key-id>

# Test encrypt/decrypt
aws kms encrypt \
  --key-id <key-id> \
  --plaintext "test" \
  --output text --query CiphertextBlob
```

### Vault Connection Failed

```bash
# Test Vault connectivity
curl $VAULT_ADDR/v1/sys/health

# Verify token
vault token lookup

# Test transit engine
vault read transit/keys/rustberg-key
```

### GCP KMS Permission Denied

```bash
# Test KMS permissions
gcloud kms keys describe rustberg-key \
  --keyring=rustberg-keyring \
  --location=global
```

### Azure Key Vault Access Denied

```bash
# Test Key Vault access
az keyvault key show \
  --vault-name rustberg-vault \
  --name rustberg-key
```

---

## Client Issues

### PyIceberg Connection Failed

```python
# Debug connection
import logging
logging.basicConfig(level=logging.DEBUG)

from pyiceberg.catalog import load_catalog
catalog = load_catalog("rustberg", uri="http://localhost:8181")
```

### Trino Connection Failed

```sql
-- Check catalog status
SHOW CATALOGS;

-- If missing, check connector config
-- catalog/rustberg.properties
```

---

## Debugging Tools

### Enable Debug Logging

```bash
# Via environment variable
RUSTBERG_LOG_LEVEL=debug ./rustberg

# Via config
[logging]
level = "debug"
```

{: .note }
> **Debug output is safe**: Rustberg uses custom `Debug` trait implementations that automatically redact sensitive data like API key hashes, secret access keys, and tokens. You can safely enable debug logging without leaking credentials.

### Health Checks

```bash
# Liveness
curl http://localhost:8181/health

# Readiness (includes storage health)
curl http://localhost:8181/ready

# Metrics (including KMS metrics if encryption is enabled)
curl http://localhost:8181/metrics
```

### Audit Logs

```bash
# View recent auth events
tail -f /var/log/rustberg/audit.log | jq

# Filter by event type
grep "authz_deny" audit.log | jq
```

### Request Tracing

```bash
# Include request ID in all requests
curl -H "X-Request-Id: debug-123" \
     -H "Authorization: Bearer $API_KEY" \
     http://localhost:8181/v1/namespaces

# Find in logs
grep "debug-123" /var/log/rustberg/app.log
```

---

## Getting Help

### Collect Diagnostics

Before opening an issue, collect:

1. **Rustberg version:**
   ```bash
   ./rustberg --version
   ```

2. **Configuration (sanitized):**
   ```bash
   cat config.toml | grep -v -E "(key|secret|password|token)"
   ```

3. **Error logs:**
   ```bash
   tail -100 /var/log/rustberg/app.log
   ```

4. **System info:**
   ```bash
   uname -a
   ```

### Support Channels

- [GitHub Issues]https://github.com/hupe1980/rustberg/issues - Bug reports
- [GitHub Discussions]https://github.com/hupe1980/rustberg/discussions - Questions

---

## Next Steps

- [Configuration]/rustberg/docs/configuration - Full config reference
- [Security]/rustberg/docs/security - Security best practices
- [API Reference]/rustberg/docs/api - Endpoint documentation