Skip to content

Commit

Permalink
Fix active query count after error (#15)
Browse files Browse the repository at this point in the history
Make sure the active query count is correctly decreased after an error
occurs.
  • Loading branch information
dekkers authored Jul 24, 2023
1 parent 9c21c4a commit 11248ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/xtdb_http_multinode/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,10 @@
(if node
(do
(swap! active-queries-per-node active-query-inc node-name)
(let [ret (handler (assoc request :xtdb-node node))]
(swap! active-queries-per-node active-query-dec node-name)
ret))
(try
(handler (assoc request :xtdb-node node))
(finally
(swap! active-queries-per-node active-query-dec node-name))))
{:status 404, :body {:error "Node not found"}}))
(handler request)))))

Expand Down
8 changes: 8 additions & 0 deletions tests/test_xtdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ def test_submit_tx(xtdb_node):

assert entity['xt/id'] == 'boris'
assert entity['last-name'] == 'Petrov'


def test_malformed(xtdb_node):
edn_headers = {'Content-Type': 'application/edn', 'Accept': 'application/adn'}

data = '{:tx-ops [[]]}'
response = requests.post(f'http://127.0.0.1:3000/_xtdb/{xtdb_node}/submit-tx', headers=edn_headers, timeout=5, data=data)
assert response.status_code == 400

0 comments on commit 11248ad

Please sign in to comment.