Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

QSTAT only returns data once in a while #8

Closed
jedwardsaviata opened this issue May 20, 2016 · 4 comments
Closed

QSTAT only returns data once in a while #8

jedwardsaviata opened this issue May 20, 2016 · 4 comments

Comments

@jedwardsaviata
Copy link

When I run the QSTAT command it mostly returns null. However, every so often it will come back with the stats for the queue. I have found that a number of attempts in quick succession often result in the stats showing up eventually.

Perhaps this has something to do with the client not waiting for the result of the QSTAT command, then receiving them on subsequent calls because the data becomes available later.

I am have configured the client with usePromise set to true. I am connected to a 3-node cluster, with each host on a separate IP.

Please let me know if there is any additional detail I can provide.

@zensh
Copy link
Member

zensh commented May 24, 2016

Hi, how do you use this command? There is no problem in my test.

callback style:

client.addjob('queue', 'message', 1000)(function (err, res) {
  console.log(111, err, res)
  this.qstat('queue')((err, res) => {
    console.log(222, err, res)
  })
})

generator style:

const thunk = require('thunks')()
thunk(function * () {
  console.log(111, yield client.addjob('queue', 'message', 1000))
  console.log(222, yield client.qstat('queue'))
})(console.error.bind(console))

@jedwardsaviata
Copy link
Author

I am using the promise API. I am using the QSTAT command on 4 queues in sequence. The first run typically works without issue. However, subsequent calls often result in most or all of the responses coming back null.

My script:

disque = require 'thunk-disque'

cluster = [
  'disque-0q:7711'
  'disque-1q:7711'
  'disque-2q:7711'
] 

client = disque.createClient(cluster, {usePromise: true})

jsonify = (obj) -> JSON.stringify(obj, null, 2)

client.info()
.then (info) -> console.log "Info: #{jsonify info}"

.then -> client.hello()
.then (hello) -> console.log "Hello: #{jsonify hello}"

.then -> client.qstat 'queue-A'
.then (stats) -> console.log "'queue-A' stats:\n#{jsonify stats}"

.then -> client.qstat 'queue-B'
.then (stats) -> console.log "'queue-B' stats:\n#{jsonify stats}"

.then -> client.qstat 'queue-C'
.then (stats) -> console.log "'queue-C' stats:\n#{jsonify stats}"

.then -> client.qstat 'queue-D'
.then (stats) -> console.log "'queue-D' stats:\n#{jsonify stats}"

.then -> client.end()                                                                                                                    

.catch (error) ->
  console.error "Error: #{error}\n#{error.stack}"

Results:

Info: {
  "disque_version": "1.0-rc1",
  "disque_git_sha1": "00000000",
  "disque_git_dirty": "0",
  "disque_build_id": "34db0b7fa4674871",
  "os": "Linux 3.16.0-62-generic x86_64",
  "arch_bits": "64",
  "multiplexing_api": "epoll",
  "gcc_version": "4.9.2",
  "process_id": "1568",
  "run_id": "86ecc7275b2758c62e6bd0fdc3495f08e7ae8e3d",
  "tcp_port": "7711",
  "uptime_in_seconds": "4660960",
  "uptime_in_days": "53",
  "hz": "10",
  "executable": "/usr/local/bin/disque-server",
  "config_file": "/etc/disque.conf",
  "connected_clients": "2",
  "client_longest_output_list": "0",
  "client_biggest_input_buf": "0",
  "blocked_clients": "0",
  "used_memory": "3080336",
  "used_memory_human": "2.94M",
  "used_memory_rss": "38268928",
  "used_memory_peak": "57425920",
  "used_memory_peak_human": "54.77M",
  "mem_fragmentation_ratio": "12.42",
  "mem_allocator": "jemalloc-4.0.3",
  "registered_jobs": "4000",
  "registered_queues": "1",
  "loading": "0",
  "aof_enabled": "0",
  "aof_state": "off",
  "aof_rewrite_in_progress": "0",
  "aof_rewrite_scheduled": "0",
  "aof_last_rewrite_time_sec": "-1",
  "aof_current_rewrite_time_sec": "-1",
  "aof_last_bgrewrite_status": "ok",
  "aof_last_write_status": "ok",
  "total_connections_received": "481",
  "total_commands_processed": "1030171",
  "instantaneous_ops_per_sec": "0",
  "total_net_input_bytes": "76067100",
  "total_net_output_bytes": "199495472",
  "instantaneous_input_kbps": "0.00",
  "instantaneous_output_kbps": "0.00",
  "rejected_connections": "0",
  "latest_fork_usec": "0",
  "used_cpu_sys": "3177.21",
  "used_cpu_user": "1217.66",
  "used_cpu_sys_children": "0.00",
  "used_cpu_user_children": "0.00"
}
Hello: [
  1,
  "551e986ef536dbe80123194120e2978c96724224",
  [
    "551e986ef536dbe80123194120e2978c96724224",
    "172.27.34.142",
    "7711",
    "1"
  ],
  [
    "53287f19e098b740ee52769acaf28248bdf6c0a9",
    "172.27.34.140",
    "7711",
    "1"
  ],
  [
    "e2b4e9e019d479e66dd25c4ae0c692d62b238328",
    "172.27.34.141",
    "7711",
    "1"
  ]
]
'queue-A' stats:
{
  "name": "queue-A",
  "len": 0,
  "age": 249,
  "idle": 10,
  "blocked": 0,
  "import-from": [],
  "import-rate": 0,
  "jobs-in": 5,
  "jobs-out": 4,
  "pause": "none"
}
'queue-B' stats:
null
'queue-C' stats:
null
'queue-D' stats:
null

@zensh
Copy link
Member

zensh commented May 24, 2016

You should add job to queue before qstat

client.addjob('queue-A', 'msg1', 1000)

@jedwardsaviata
Copy link
Author

Good to know. I will do this moving forward. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants