Skip to content

Commit 18dd02b

Browse files
author
Steve Ramage
committed
Resolves #647 - Fixes typos in Mongo advisory locking parameters
1 parent 9f8bb1b commit 18dd02b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

database/mongodb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
| `x-transaction-mode` | `TransactionMode` | If set to `true` wrap commands in [transaction](https://docs.mongodb.com/manual/core/transactions). Available only for replica set. Driver is using [strconv.ParseBool](https://golang.org/pkg/strconv/#ParseBool) for parsing|
1616
| `x-advisory-locking` | `true` | Feature flag for advisory locking, if set to false, disable advisory locking |
1717
| `x-advisory-lock-collection` | `migrate_advisory_lock` | The name of the collection to use for advisory locking.|
18-
| `x-advisory-lock-timout` | `15` | The max time in seconds that the advisory lock will wait if the db is already locked. |
19-
| `x-advisory-lock-timout-interval` | `10` | The max timeout in seconds interval that the advisory lock will wait if the db is already locked. |
18+
| `x-advisory-lock-timeout` | `15` | The max time in seconds that migrate will wait to acquire a lock before failing. |
19+
| `x-advisory-lock-timeout-interval` | `10` | The max time in seconds between attempts to acquire the advisory lock, the lock is attempted to be acquired using an exponential backoff algorithm. |
2020
| `dbname` | `DatabaseName` | The name of the database to connect to |
2121
| `user` | | The user to sign in as. Can be omitted |
2222
| `password` | | The user's password. Can be omitted |

database/mongodb/mongodb.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ func (m *Mongo) Open(dsn string) (database.Driver, error) {
137137
if err != nil {
138138
return nil, err
139139
}
140-
maxLockingIntervals, err := parseInt(unknown.Get("x-advisory-lock-timout-interval"), DefaultLockTimeoutInterval)
140+
141+
lockTimeout := unknown.Get("x-advisory-lock-timeout-interval")
142+
143+
if lockTimeout == "" {
144+
// The initial release had a typo for this argument but for backwards compatibility sake, we will keep supporting it.
145+
lockTimeout = unknown.Get("x-advisory-lock-timout-interval")
146+
}
147+
148+
maxLockCheckInterval, err := parseInt(lockTimeout, DefaultLockTimeoutInterval)
149+
141150
if err != nil {
142151
return nil, err
143152
}
@@ -157,7 +166,7 @@ func (m *Mongo) Open(dsn string) (database.Driver, error) {
157166
CollectionName: lockCollection,
158167
Timeout: lockingTimout,
159168
Enabled: advisoryLockingFlag,
160-
Interval: maxLockingIntervals,
169+
Interval: maxLockCheckInterval,
161170
},
162171
})
163172
if err != nil {

0 commit comments

Comments
 (0)