Commit 6b33822
feat: Add retry mechanism on locked/busy mbtiles files (#2572)
Fix #1591
Hello !
This is my first-ever PR to an open-source project.
Currently, martin crashes when trying to fetch the metadata of a busy
mbtile file. It was proposed in the open issue:
#1591 to be more lenient and
perform retries when the file was locked.
### Technical note:
The `SQLITE_BUSY` error is hardcoded as the sqlite wrapper used in
martin (sqlx) doesn't offer an error enum match for specific sqlite
error codes (unlike rusqlite).
### Retry strategy:
The retrial strategy is an exponential backoff with the following
delays: 50ms, 0.1s, 0.2s, 0.4s, 0.8s, 1.6s, 3.2s, and finally 6.4s.
### I would happily take feedback on:
- Is limiting the retry behavior strictly to SQLITE_BUSY errors the
intended approach ?
- Are the exponential backoff delays acceptable for this use case ?
- Is the warning message too verbose for the logs ?
- Is there anything else that I might have missed ? :)
Thanks !
<img width="1621" height="923" alt="Screenshot from 2026-02-24 14-09-21"
src="https://github.com/user-attachments/assets/dd0099ee-c14d-40e3-9be8-64b765bbd316"
/>
---------
Co-authored-by: Frank Elsinga <frank@elsinga.de>1 parent 7cb748b commit 6b33822
File tree
4 files changed
+71
-13
lines changed- martin-core
- src/tiles/mbtiles
4 files changed
+71
-13
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | | - | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | 53 | | |
38 | 54 | | |
| |||
41 | 57 | | |
42 | 58 | | |
43 | 59 | | |
44 | | - | |
45 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
46 | 79 | | |
47 | 80 | | |
48 | 81 | | |
49 | | - | |
50 | 82 | | |
51 | 83 | | |
52 | 84 | | |
| |||
0 commit comments