firebase-queue icon indicating copy to clipboard operation
firebase-queue copied to clipboard

Tasks Not Disappearing

Open ksinghal opened this issue 9 years ago • 15 comments

I am calling the resolve function, but the task seems to be reclaimed instantly by the worker even after it has already been completed. In other words, the tasks never complete - they keep happening over and over infinitely... I have added a screenshot of my spec if that helps screen shot 2016-05-26 at 7 24 19 am

ksinghal avatar May 26 '16 11:05 ksinghal

I don't think this is the same as #48, because I do not have any indexes in my firebase. However, my problem is exactly the sync vs async issue described in this comment: https://github.com/firebase/firebase-queue/issues/48#issuecomment-208400101

I am unable to resolve tasks async, only sync.

ksinghal avatar May 26 '16 11:05 ksinghal

Please provide a minimal repro and also sample data including what the task event looks like at each point in the process (not just the spec).

katowulf avatar May 26 '16 16:05 katowulf

Also, hi!! Welcome! ☃☃☃

katowulf avatar May 26 '16 16:05 katowulf

  • Edited to remove extraneous ExpressJS code from repro.
  • Edited for typos and removed my personal Firebase URL.

Hi Katowulf, thank you for your prompt response! Here is an example of server side NodeJS code that reproduces this issue. I am using node v5.5.0, and using firebase 2.4.2, and have tried using firebase-queue 1.3.0, 1.3.1, and 1.4.0

var Queue = require('firebase-queue'), Firebase = require('firebase');

var ref = new Firebase(***FIREBASE_URL***);
var queue = new Queue(ref.child('queues').child('create_reservation'), {'numWorkers' : 1, 'specId' : 'default_spec'}, function(data, progress, resolve, reject) {
    setTimeout(function() { resolve(data); }, 3000);
});

The task goes between the two states in the attached images: screen shot 2016-05-26 at 1 10 11 pm screen shot 2016-05-26 at 1 10 21 pm

ksinghal avatar May 26 '16 17:05 ksinghal

Could you include your specs and share some of the code that adds onto the queue. Also, is the express stuff important to the repro?

cbraynor avatar May 28 '16 00:05 cbraynor

  • Edited to include code that adds tasks to the queue

Here is an image of an example spec that exhibits the behavior described. The tasks are attached to the queue, the spec worker processes them, and finally the _state, _progress, and _owner are removed and then added again. The single spec worker in the image keeps running each task over and over again and i have never seen it stop so I assume it's infinite

I have also updated my comment above to remove the unnecessary ExpressJS code

screen shot 2016-05-28 at 4 02 16 pm

Here is the iOS client code I am using to push tasks. I call this function with the variables included in the previous comment (but it doesn't matter whether I add my own information to the task or just push an "empty" task)

public func performTask(queue: String, data: [String : AnyObject], completion: (success: Bool) -> Void) {
    queueRef.child(queue).child("tasks").push(data) { error, ref in
        if error != nil { completion(success: false); return }
        queueRef.child(queue).child("tasks").child(ref.key).once(.Value) { snapshot in
            guard snapshot.exists() else {
                completion(success: true)
                return
            }
            queueRef.child(queue).child("tasks").queryOrderedByKey().queryEqualToValue(ref.key).once(.ChildRemoved) { snapshot in
                completion(success: true)
            }
        }
    }
}

ksinghal avatar May 28 '16 20:05 ksinghal

Hi, I was wondering if you needed any more information on my end to get to the bottom of this issue?

ksinghal avatar Jun 09 '16 17:06 ksinghal

+1

gvkhna avatar Jul 12 '16 21:07 gvkhna

+1

amartone avatar Jul 13 '16 00:07 amartone

Hello Firebase Team,

This issue had resolved itself for a period of a month or so, after upgrading to firebase 3.x and the new firebase queue. Now after 3 and a half months of it working properly with asynchronous resolves, and with zero code changes on my end it has reappeared today unexpectedly. I am fairly frustrated and confused as I am not sure what is leading to this issue. It seems to pop up unexpectedly and not due to changes on my end

ksinghal avatar Sep 12 '16 19:09 ksinghal

UPDATE:

Now I am getting worried, because after popping up for a period of 2 hours, the issue resolved itself again with no modification of my system's code. As I am hoping to put my applications into production soon, I really do not want to risk a re-ocurrence of this issue without a known cause or way to mitigate it. Thank you again for your continued support, I look forward to hearing back

ksinghal avatar Sep 12 '16 22:09 ksinghal

@ksinghal Kinda a long shot question here, but did you redeploy your code at all? If it was reinstalled without a specific enough (using ^) package.json file you might be getting a different version of firebase or another dependency then you had before. I had this happen when changing absolutely 0 code and pushing just for a change in a README.

Example: Your package file has something like ^3.0.0 and everything was working before on 3, as soon as a patch is released and you reinstall you will be on that changed version (maybe 3.0.1).

prescottprue avatar Sep 12 '16 22:09 prescottprue

I simply restarted the server locally, without redeploying and without running "npm install"

ksinghal avatar Sep 12 '16 22:09 ksinghal

to clarify, I restarted the server many times without making modifications, and the issue was still present. Then, all of a sudden after a few hours the issue just seemed to stop happenning

ksinghal avatar Sep 12 '16 22:09 ksinghal

Possibly related to #48.

katowulf avatar Sep 19 '16 21:09 katowulf