Understanding the Sync Problem in Fossil
What Is a Sync Inconsistency?
Fossil sync inconsistencies occur when clones do not reflect the latest changes or histories diverge subtly due to improper pull/push operations, timezone mismatches, or incomplete sync states. This often results in missing commits, out-of-date tickets, or broken timelines.
fossil sync --verbose # Output shows missing artifacts or no-op syncs despite recent commits
Why It Matters in Distributed Teams
In distributed workflows, Fossil's self-contained model is both strength and challenge. Without strict sync discipline, clones drift, leading to audit inconsistencies, CI failures, or overwritten histories.
Architectural Implications
Single-File Repository Model
Fossil repositories are single SQLite files. Unlike Git, which stores objects in directories, Fossil handles all content within the DB. If this file is not safely copied, or concurrent writes occur, it can corrupt the sync state.
Autosync and Manual Modes
Fossil supports autosync (push-pull on commit) and manual sync (explicit fossil sync). Teams using mixed modes (some autosync, some not) often encounter divergence when one side assumes updates have propagated.
Diagnosing Sync and Clone Drift
Compare Clones Using Timeline Diffs
The timeline command helps compare histories between repositories. Use it to detect commits or tags missing from a remote or local clone.
fossil timeline -n 20 fossil remote-url http://yourserver:8080/repo.fossil
Check Repository Integrity
Use 'fossil test-integrity' to identify corrupted or partial syncs. This is critical after interrupted syncs, file system crashes, or binary-level file copies.
fossil test-integrity # Look for "artifact missing" or "checksum mismatch"
Review Autosync Settings
Autosync misconfiguration can lead to false assumptions about state propagation. Check current config:
fossil settings autosync # Expect: on or off
Common Pitfalls
Manual File Copying Between Clones
Copying the repository file manually (e.g., via SCP or rsync) while Fossil is running can result in corrupted state or incomplete transactions.
Timezone and Clock Skew
Commits in Fossil are timestamped in UTC. Clock skew across servers can make it appear like commits are missing or misordered, especially in timelines and tickets.
SSH Tunneling Without Sync Verification
When syncing over SSH manually, it's easy to assume success without verifying data propagation. A successful TCP connection does not imply complete artifact transfer.
Step-by-Step Fixes
Step 1: Run Integrity and Timeline Checks
Ensure all clones pass integrity tests and align timelines:
fossil test-integrity fossil timeline -n 50 --type ci
Step 2: Resync With '--once' to Force Full Sync
Use the '--once' flag to force a single sync session. If unsure, explicitly push and pull both directions:
fossil sync --once --verbose fossil push --verbose fossil pull --verbose
Step 3: Align Autosync Across Team
Ensure all developers have consistent autosync settings:
fossil settings autosync on
Step 4: Repair Missing Artifacts
Run rebuild on potentially corrupted repositories to restore state:
fossil rebuild
Step 5: Validate Remote Repos Periodically
Schedule integrity tests on server-side repositories and enforce sync logs on CI triggers to catch drift early.
Best Practices to Avoid Sync Problems
- Always sync before and after local commits.
- Avoid manual file copying—use 'fossil sync' or 'clone'.
- Standardize autosync and keep clocks in sync via NTP.
- Document sync responsibilities in team workflows.
- Backup only after ensuring 'fossil test-integrity' passes.
Conclusion
Fossil's design encourages simplicity, but that doesn't exempt it from complexity in distributed use. Sync issues arise subtly but can have critical downstream effects, especially in regulated or automated environments. The key is proactive consistency—testing integrity, verifying syncs, and standardizing team workflows. By understanding Fossil's architectural nuances and enforcing disciplined practices, teams can leverage its full power without the pitfalls of silent divergence.
FAQs
1. Can I sync Fossil over HTTPS securely in production?
Yes. Fossil supports HTTPS with login tokens and SSL certificates. Ensure your server uses HTTPS with properly configured access control and TLS.
2. What's the difference between 'clone' and 'sync' in Fossil?
'clone' initializes a new repository copy from a remote source, while 'sync' exchanges changes between existing repositories. Cloning does not set up ongoing sync unless configured.
3. How do I detect commit divergence between two Fossil repositories?
Use 'fossil timeline' and compare output from both repositories. You can also use SHA1 tags to verify commit presence and ordering.
4. Is autosync always recommended?
In small teams or high-collaboration workflows, yes. In CI/CD or controlled deployments, manual sync gives more control but demands discipline.
5. How does Fossil handle concurrent syncs?
Fossil uses a locking mechanism to serialize sync transactions. Concurrent syncs are queued, but forced interruptions can result in incomplete artifact transfer. Always let sync complete before new operations.