MerginMaps / MerginMaps/db-sync

A failed initial run of db-sync may leave broken project folder half-initialized

Open
#174 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
53
Forks
24
PR merge metrics
No merged PRs in 30d

Description

It may happen that if db-sync failed during initialization, the project folder can exist, and then it blocks further db-sync runs. If we have a failure during init, we should make sure to clean up the project directory to avoid such issue:

```
PS C:\Users\ivana\Documents\DB SYNC> .\dbsync_daemon.exe config.yaml
== starting mergin-db-sync daemon == version 2.1.1 ==
Using config file: config.yaml
Email notifications for sync failures are not set up. It is recommended to use them. Please see documentation.
Logging in to Mergin...
Going to log in user [ivana.kuklicova@lutraconsulting.co.uk](mailto:ivana.kuklicova@lutraconsulting.co.uk)
User ivana.kuklicova successfully logged in.
Processing Mergin Maps project 'Iva Testing/test_db_sync'
Connecting to the database...
Modified and base schemas already exist
Error: Project metadata has not been created yet
Removing local working directory C:/Users/ivana/AppData/Local/Temp/dbsync\test_db_sync
Traceback (most recent call last):
  File "dbsync.py", line 1163, in init
  File "dbsync.py", line 549, in _get_project_version
  File "mergin\merginproject.py", line 138, in metadata
mergin.common.InvalidProject: Project metadata has not been created yet
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with init in dbsync.py around line 1163 and the _get_project_version call around line 549; reproduce the failed initialization with config.yaml. Verify that an initialization failure removes the local project directory and that a subsequent db-sync run is no longer blocked.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.