rfcx / arbimon

Ecoacoustic analysis platform empowering conservationists to analyze acoustic data and to derive insights about the ecosystem at scale
https://arbimon.org
Apache License 2.0
5 stars 1 forks source link

Delete function on Recordings page isn't working #2117

Closed koonchaya closed 3 weeks ago

koonchaya commented 3 weeks ago

From: wendy.estes-zumpf@wyo.gov

Image

I am trying to delete recordings and sites that I no longer need. If I filter the recordings that I want to delete, the "delete all filtered recordings" option does nothing. "Delete checked recordings" does give me a pop-up asking if I want to delete them, but nothing is deleted when I click "delete". I also cannot delete the sites related to any of those recordings. If I select a site and click "delete selected site", it askes me if I want to delete. If I click yes, nothing happens.

RatreeOchn commented 3 weeks ago
Screenshot 2567-10-31 at 12 06 20
- deleteRecordingsInCoreAPI [ { stream: 'pjp3y91hefm9', starts: [ '2023-06-19T17:24:00.000Z' ] } ]
ALERT: connection taken for query DELETE FROM pattern_matching_rois_new WHERE recording_id in (211425422) is not freed after 25000
ALERT: request to "/legacy-api/project/world-1/recordings/delete" did not finish in the treshold 35000
err Error: ER_LOCK_WAIT_TIMEOUT: Lock wait timeout exceeded; try restarting transaction
    at Query.Sequence._packetToError (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (node:events:369:20)
    at Socket.emit (node:domain:470:12)
    --------------------
    at Protocol._enqueue (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at PoolConnection.query (/Users/ratree/Documents/RFCx_work/arbimon-legacy/node_modules/mysql/lib/Connection.js:198:25)
    at PoolConnection.connection.query (/Users/ratree/Documents/RFCx_work/arbimon-legacy/app/utils/dbpool.js:61:26)
    at node:internal/util:325:7
    at new Promise (<anonymous>)
    at PoolConnection.<anonymous> (node:internal/util:311:12)
    at Object.deleteRecordingInAnalyses (/Users/ratree/Documents/RFCx_work/arbimon-legacy/app/model/recordings.js:2132:19)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async /Users/ratree/Documents/RFCx_work/arbimon-legacy/app/model/recordings.js:2176:17
From previous event:
    at Object.delete (/Users/ratree/Documents/RFCx_work/arbimon-legacy/app/model/recordings.js:2149:14)
    at /Users/ratree/Documents/RFCx_work/arbimon-legacy/app/routes/data-api/project/recordings.js:459:32 {
  code: 'ER_LOCK_WAIT_TIMEOUT',
  errno: 1205,
  sqlMessage: 'Lock wait timeout exceeded; try restarting transaction',
  sqlState: 'HY000',
  index: 0,
  sql: 'DELETE FROM pattern_matching_rois_new WHERE recording_id in (211425422)'
}
Error: Failed to delete recordings
    at /Users/ratree/Documents/RFCx_work/arbimon-legacy/app/model/recordings.js:2199:23
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
From previous event:
    at Object.delete (/Users/ratree/Documents/RFCx_work/arbimon-legacy/app/model/recordings.js:2193:19)
    at /Users/ratree/Documents/RFCx_work/arbimon-legacy/app/routes/data-api/project/recordings.js:459:32
RatreeOchn commented 3 weeks ago
error: POST 500 /legacy-api/project/world-1/recordings/delete Response Time: 59340 Authorization: undefined Email: ratree@rfcx.org Body: {"recs":[{"id":211425422,"file":"7bc09b90-8825-416c-ad8a-ea852e81055d.flac","uri":"2023/06/19/pjp3y91hefm9/7bc09b90-8825-416c-ad8a-ea852e81055d.flac","datetime":"2023-06-20T00:24:00.000Z","datetime_utc":"2023-06-19T17:24:00.000Z","upload_time":"2024-10-28T15:17:42.000Z","duration":60,"mic":"Unknown","recorder":"AudioMoth","version":"Unknown","sample_rate":192000,"meta":{"comment":"Recorded at 20:24:00 19/06/2023 (UTC+3) by AudioMoth 248D9B0260371D25 at medium gain while battery was 4.3V and temperature was 24.8C. Band-pass filter with frequencies of 0.0kHz and 96.0kHz applied.","artist":"AudioMoth 248D9B0260371D25","encoder":"Lavf58.24.101","filename":"20230619_202400.WAV"},"site_id":65493,"site":"w 001","legacy":false,"site_external_id":"pjp3y91hefm9","timezone":"Asia/Bangkok","utc":"UTC+7","imported":false,"comments":"248D9B0260371D25 / medium gain / 24.8C","filename":"20230619_202400.WAV","thumbnail":"/legacy-api/ingest/recordings/pjp3y91hefm9_t20230619T172400000Z.20230619T172500000Z_z95_wdolph_g1_fspec_mtrue_d420.154.png","checked":true}]} {"meta":{}}
RatreeOchn commented 3 weeks ago

Here's the code for deleting recording.

deleteRecordingInAnalyses: async function(recIds, queryExecutor) {
        const queryFn = queryExecutor || dbpool.query;

        let queries = [
            `DELETE FROM audio_event_detections_clustering WHERE recording_id in (${recIds})`,
            `DELETE FROM classification_results WHERE recording_id in (${recIds})`,
            `DELETE FROM pattern_matching_rois_new WHERE recording_id in (${recIds})`,
            `DELETE FROM soundscape_region_tags WHERE recording_id in (${recIds})`,
            `UPDATE templates set deleted=1 WHERE recording_id in (${recIds})`,
            `DELETE FROM training_set_roi_set_data WHERE recording_id in (${recIds})`
        ];

        for (let query of queries) {
            await queryFn(query)
        }
    }
Screenshot 2567-10-31 at 13 42 40