Taking too long to update database

20 views
Skip to first unread message

Zolf

unread,
Jul 2, 2022, 10:35:56 AM7/2/22
to vert.x
Hi there,

I have my logic like so, after 3 compose, I have to finally update a table to setDate. But for some reason it takes around 4 mins as you can see in the console log below. I will appreciate any help!!

public Future<String> startPrintJob(int jobID, RoutingContext context) {
        LOG.info("-----INside startPrint() method-----");
        LabelParameterContext labelParameterCtx = new LabelParameterContext();
        return jobDao.getJob(jobID, context)
                .compose(job -> productDao.getLabelParameters(job, context))
                .compose(labelParameters -> {
                    labelParameterCtx.setLabelParameters(labelParameters);
                    return jobDao.getJobParentChildForPrint(jobID, context, false, labelParameters);
                })
                .compose(parentChildSerials -> {
                        LOG.debug(" Future Returned Job's Parent-Child to Print: ");
                        //LOG.debug(" ZZZZZ::: "+parentChildSerials);        
                        JsonObject labelParameters = labelParameterCtx.getLabelParameters();
                        try {        
                            prepareSerialForPrint(parentChildSerials, labelParameters);
                        } catch (UnknownHostException e) {
                            e.printStackTrace();
                        } //Pass Here
                        return Future.succeededFuture("Job Completed Successfully!!!!");
                })
            .onFailure(error -> {
                    LOG.debug("startTest() Failed: ", error);
                  })
            .onSuccess(server -> {
                    LOG.debug("Finished !!");
                    //LOG.debug(server.encodePrettily());
                   
                    jobDao.setJobFinishedDate(jobID);
                  });
    }//startPrintJob()


CONSOLE LOG

2022-07-02 18:47:52.077+0430
[vert.x-eventloop-thread-1] DEBUG com.ali.dao.JobDao - Tuple for Parent UID values: [2022-07-02 18:47:52,11]
2022-07-02 18:47:52.078+0430 [vert.x-eventloop-thread-1] DEBUG com.ali.job.PrintJobHandler -  parentChildSerials   Future{result=Job Completed Successfully!!!!}
2022-07-02 18:51:43.735+0430 [vert.x-eventloop-thread-1] DEBUG com.ali.dao.JobDao - Updated job table's finished_on column!!!!!!!!!!!!!!!!!!!!!!!!! 

Thomas SEGISMONT

unread,
Jul 4, 2022, 4:50:27 AM7/4/22
to ve...@googlegroups.com
The last log statement seems to be caused by code that is not shown on the snippet.

Perhaps there are other operations happening elsewhere?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/c380e71e-ae50-4f90-898e-e665a2be9bben%40googlegroups.com.

Zolf

unread,
Jul 4, 2022, 5:46:52 AM7/4/22
to vert.x
Thanks for your feedback. Appreciate it

This is the last method which gets called to update the DB table and takes a long time. Regarding to your question, how can I debug it or identify it?

public void setJobFinishedDate(int jobID) {
        LOG.debug("Inside setJobFinishedDate() "+jobID);
        //var one = Promise.<Void>promise();
        LocalDateTime issuedAt = LocalDateTime.now();
        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");        
       
        Tuple batch = Tuple.of(issuedAt.format(format), jobID);

        LOG.debug("Tuple for Parent UID values: " + batch.deepToString());

        // Execute the query
        db.preparedQuery("UPDATE job SET finished_on=? WHERE id=?;").execute(batch, res -> {
            if (res.succeeded()) {
                LOG.debug("Updated job table's finished_on column!!!!!!!!!!!!!!!!!!!!!!!!! ");
                //one.complete();
            } else {
                System.out.println("Batch failed for UPDATE job table's finished_on column!!" + res.cause());
            }
        });
    }

Thomas SEGISMONT

unread,
Jul 4, 2022, 6:06:17 AM7/4/22
to ve...@googlegroups.com
Perhaps you can take a look at the slow queries log of your database to confirm that "UPDATE job SET finished_on=? WHERE id=?" is the culprit

Z.A Jafari

unread,
Jul 4, 2022, 6:16:09 AM7/4/22
to ve...@googlegroups.com
From your point of view am i using the correct vertx code conduct to update db.

You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/KCMByUpMIXo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/CACiEr_Ty5UogKXmTFT7ngPHq1Spp6MGWTWuzHUoJ6N0J%2B3aA%2Bw%40mail.gmail.com.

Thomas SEGISMONT

unread,
Jul 4, 2022, 6:30:35 AM7/4/22
to ve...@googlegroups.com
I can't see anything wrong from the snippets

Reply all
Reply to author
Forward
0 new messages