Skip to content

Commit

Permalink
Account database lock exception fixed (#1267)
Browse files Browse the repository at this point in the history
* Accounts database lock exception fixed

Enable "Write-Ahead Logging" instead of a rollback journal when using SQLite - https://www.sqlite.org/wal.html

# Description
This fix solves bug with accounts going into cool down because of database locks wile reading.

# Motivation and Context
This fixed error #1232

# How Has This Been Tested?
This has been tested with 77 workers. The accounts stopped going into cool down.

# Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

# Checklist
- [x] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.

* Update models.py

Solve problems with large pogom.db-wal file.

https://github.com/PokemonGoMap/PokemonGo-Map/pull/1267#issuecomment-246826983

* Correct a failure

* PEP8.
  • Loading branch information
Diblo authored and sebastienvercammen committed Feb 1, 2017
1 parent 5a4223b commit cd5e386
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pogom/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
import time
import geopy
import math
from peewee import SqliteDatabase, InsertQuery, \
from peewee import InsertQuery, \
Check, CompositeKey, ForeignKeyField, \
IntegerField, CharField, DoubleField, BooleanField, \
DateTimeField, fn, DeleteQuery, FloatField, SQL, TextField, JOIN
from playhouse.flask_utils import FlaskDB
from playhouse.pool import PooledMySQLDatabase
from playhouse.shortcuts import RetryOperationalError
from playhouse.migrate import migrate, MySQLMigrator, SqliteMigrator
from playhouse.sqlite_ext import SqliteExtDatabase
from datetime import datetime, timedelta
from base64 import b64encode
from cachetools import TTLCache
Expand Down Expand Up @@ -58,8 +59,13 @@ def init_database(app):
max_connections=connections,
stale_timeout=300)
else:
log.info('Connecting to local SQLite database...')
db = SqliteDatabase(args.db)
log.info('Connecting to local SQLite database')
db = SqliteExtDatabase(args.db,
pragmas=(
('journal_mode', 'WAL'),
('mmap_size', 1024 * 1024 * 32),
('cache_size', 10000),
('journal_size_limit', 1024 * 1024 * 4),))

app.config['DATABASE'] = db
flaskDb.init_app(app)
Expand Down

0 comments on commit cd5e386

Please sign in to comment.