Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scripts query empty result lead deadlock #1532

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

rabbitz
Copy link
Collaborator

@rabbitz rabbitz commented Dec 13, 2023

@rabbitz rabbitz requested a review from zmcNotafraid December 13, 2023 08:00
@rabbitz
Copy link
Collaborator Author

rabbitz commented Dec 13, 2023

"SELECT \"ckb_transactions\".* FROM \"ckb_transactions\" INNER JOIN \"cell_dependencies\" ON \"ckb_transactions\".\"id\" = \"cell_dependencies\".\"ckb_transaction_id\" WHERE \"cell_dependencies\".\"contract_id\" = 13 ORDER BY \"ckb_transactions\".\"id\" DESC LIMIT 10 OFFSET 0"

The result of this query is empty, but as soon as the order query is added, it gets stuck. Use sql SELECT * FROM pg_stat_activity; to check:

{"datid"=>14301,
  "datname"=>"postgres",
  "pid"=>18542,
  "leader_pid"=>nil,
  "usesysid"=>16395,
  "usename"=>"postgres",
  "application_name"=>"bin/rails",
  "client_addr"=>"10.10.10.157",
  "client_hostname"=>nil,
  "client_port"=>5792,
  "backend_start"=>2023-12-13 06:11:34.739254 +0000,
  "xact_start"=>2023-12-13 06:16:53.671756 +0000,
  "query_start"=>2023-12-13 06:16:53.675355 +0000,
  "state_change"=>2023-12-13 06:16:53.675355 +0000,
  "wait_event_type"=>"IO",
  "wait_event"=>"DataFileRead",
  "state"=>"active",
  "backend_xid"=>nil,
  "backend_xmin"=>"1025555882",
  "query"=>"SELECT \"ckb_transactions\".* FROM \"ckb_transactions\" INNER JOIN \"cell_dependencies\" ON \"ckb_transactions\".\"id\" = \"cell_dependencies\".\"ckb_transaction_id\" WHERE \"cell_dependencies\".\"contract_id\" = $1 ORDER BY \"ckb_transactions\".\"id\" DESC LIMIT $2 OFFSET $3",
  "backend_type"=>"client backend"}

@zmcNotafraid

@codecov-commenter
Copy link

Codecov Report

Attention: 198 lines in your changes are missing coverage. Please review.

Comparison is base (bb447e4) 66.37% compared to head (eba51fc) 67.51%.
Report is 156 commits behind head on develop.

❗ Current head eba51fc differs from pull request most recent head 5fe5acd. Consider uploading reports for the commit 5fe5acd to get more accurate results

Files Patch % Lines
...ib/tasks/migration/update_output_cells_status.rake 29.26% 29 Missing ⚠️
lib/tasks/migration/generate_referring_cells.rake 19.23% 21 Missing ⚠️
.../controllers/api/v1/ckb_transactions_controller.rb 39.28% 17 Missing ⚠️
app/workers/token_transfer_detect_worker.rb 10.52% 17 Missing ⚠️
...ib/tasks/migration/async_missing_transactions.rake 15.78% 16 Missing ⚠️
app/workers/contract_statistic_worker.rb 0.00% 15 Missing ⚠️
app/controllers/api/v2/scripts_controller.rb 69.76% 13 Missing ⚠️
app/models/ckb_sync/new_node_data_processor.rb 72.34% 13 Missing ⚠️
lib/websocket.rb 0.00% 10 Missing ⚠️
lib/scheduler.rb 0.00% 7 Missing ⚠️
... and 14 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1532      +/-   ##
===========================================
+ Coverage    66.37%   67.51%   +1.13%     
===========================================
  Files          275      284       +9     
  Lines         7397     7674     +277     
===========================================
+ Hits          4910     5181     +271     
- Misses        2487     2493       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rabbitz rabbitz added this pull request to the merge queue Dec 13, 2023
Merged via the queue into nervosnetwork:develop with commit 54d5fe6 Dec 13, 2023
1 check passed
@rabbitz rabbitz deleted the fix/scripts_query branch December 13, 2023 09:17
tianlitao pushed a commit to tianlitao/ckb-explorer that referenced this pull request Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants