Dear Community,
I have setup ACCDB module to save missed / failed and successful calls.

My issue is that i am getting duplicated entries for INVITE / BYE in acc database table.

For example:
id;method;from_tag;to_tag;callid;sip_code;sip_reason;time;src_ip;dst_user;dst_domain;src_user;src_domain;cdr_id
231838;INVITE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:28;22.33.44.55;nlb124#78019989897056;11.11.11.11;asterisk;172.16.0.35;0
231839;INVITE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:28;22.33.44.55;nlb124#78019989897056;11.11.11.11;asterisk;172.16.0.35;0
231840;INVITE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:28;22.33.44.55;nlb124#78019989897056;11.11.11.11;asterisk;172.16.0.35;0
231841;BYE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:36;22.33.44.55;;190.196.153.130;asterisk;172.16.0.35;0
231842;BYE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:36;22.33.44.55;;190.196.153.130;asterisk;172.16.0.35;0
231844;BYE;21-7FC1D85;1914472180948750;KKyIdaaJceAu7pzN@172.16.0.35;200;OK;2020-02-11 19:16:36;22.33.44.55;;190.196.153.130;asterisk;172.16.0.35;0

Following way: 
# ----- acc params -----
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 0)
modparam("acc", "report_cancels", 0)
/* by default ww do not adjust the direct of the sequential requests.
 * if you enable this parameter, be sure the enable "append_fromtag"
 * in "rr" module */
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "log_missed_flag", FLT_ACCMISSED)
modparam("acc", "log_extra",
        "src_user=$fU;src_domain=$fd;src_ip=$si;"
        "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
/* enhanced DB accounting */
#!ifdef WITH_ACCDB
modparam("acc", "db_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "db_url", DBURL)
#modparam("acc", "db_extra",
#       "src_user=$fU;src_domain=$fd;src_ip=$si;"
#       "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
modparam("acc", "db_extra",
        "src_user=$fU;src_domain=$fd;dst_user=$rU;dst_domain=$rd;src_ip=$si")

#  our lines
modparam("acc", "cdrs_table", "acc_cdrs")
modparam("acc", "cdr_on_failed", 1)
#!endif

Then in routing config i set setflag(FLT_ACC FLT_ACCMISSED FLT_ACCFAILED in several places.

My question is - each setflag cause an entry to be saved in DB?
How can i debug and resolve the issue of duplicates.

I am trying to use a CDR script found somewhere on siremis sites to do the accounting but it's making trouble because due to duplicates in acc table i am getting cdrs unique key violations.

Secondary question is - if a BYE is not received / lost is there any way to send a check triggered by kamailio to each caller and callee side to check if dialog is still active.
I would not like to use session timers (as endpoints need to support it).

Best regards,
Tom