ORNL / DataFed

A Federated Scientific Data Management System
https://ornl.github.io/DataFed/
Other
18 stars 14 forks source link

Strange Retry Block #821

Open JoshuaSBrown opened 2 years ago

JoshuaSBrown commented 2 years ago
        var delay = 1;
        for(;;){
            try{
                g_db.task.update( a_task_id, doc );
                break;
            }
            catch( e ){
                if ( e.errorNum == 1200 ){
                    if ( delay > 64 )
                        throw e;

                    //console.log("retry sleep");
                    g_internal.sleep(0.2*delay);
                    //console.log("do retry");

                    delay *= 2;
                }else{
                    throw e;
                }
            }
        }

Weird retry block in code in task.js lines around 1100.

dvstans commented 2 years ago

FYI, this is to handle write-write conflicts in the DB. Arango does not handle concurrent writes, so throws an error for the application to deal with. In this case we use a progressive back-off timer until it works or we give up. There probably should be a clean wrapper function for handling write conflicts in general - and if they ultimately fail - there should be a notification / handler for that b/c the system is probably in an invalid state at that point.

JoshuaSBrown commented 1 year ago

Thanks for the clarification.