AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
138 stars 84 forks source link

handle SQLITE_BUSY #435

Closed xlc closed 1 year ago

xlc commented 1 year ago
2023-10-12 13:55:23        REGISTRY: Unknown signed extensions SetEvmOrigin found, treating them as no-effect
/Users/xiliangchen/projects/acala/chopsticks/node_modules/typeorm/src/driver/sqlite/SqliteQueryRunner.ts:113
                    fail(new QueryFailedError(query, parameters, err))
                         ^
QueryFailedError: SQLITE_BUSY: database is locked
    at Statement.handler (/Users/xiliangchen/projects/acala/chopsticks/node_modules/typeorm/src/driver/sqlite/SqliteQueryRunner.ts:113:26) {
  query: 'INSERT INTO "key_value_pair"("blockHash", "key", "value") VALUES (?, ?, ?) ON CONFLICT ( "key", "blockHash" ) DO UPDATE SET "key" = EXCLUDED."key", "blockHash" = EXCLUDED."blockHash", "value" = EXCLUDED."value"',
  parameters: [
    '0xeafd4ab80514098b700bb466ae41634ce5ebf77ba29000ef53c2b0c0ed121ef9',
    '0xcec5070d609dd3497f72bde07fc96ba088dcde934c658227ee1dfafcd6e16903',
    '0x24b210cf0dbf420316bc903243152a71e9a851f7b407c9e39c0f3c152cfdcbc6151e30aa51ad68b8918d2c46e914986818c111bee03582610cbc9fb73fe0e4c4134660eeb3476a1684be209384c5deb03cbaf0ba405f5092cfe8c34dd3b6df353e4c99b4a7baea915dad709a6bc04dbd5098661219be8059b212310f733925fc1654ddd7080a732e544a88a2c0b52c8b793b08bfc9a0ffbbcc6591d697496f8d0f5ac09ed30bf9c17475373689bb8965cf5c3cd9cff1894f407310acd892d4f1659a9403f1b8480ce61732b01a1450dd5ab5978dbd9502aec13498e607400d8812c8ace959897f86f0075f213815c871662fe66a1f37356499e68d13f649ac437ce6dc327fff79c98872e22b11aef9829c602ed02829876534d0c5a6a48f216d10'
  ],
  driverError: [Error: SQLITE_BUSY: database is locked] {
    errno: 5,
    code: 'SQLITE_BUSY'
  },
  errno: 5,
  code: 'SQLITE_BUSY'
}

should handle the error and retry the query

this happens when multiple instances are accessing a same db file concurrently