Realtime extensions, Duplicate queries?

I’m toying with the idea of replacing a statically generated file I include in my extensions.conf with a realtime database.

I’ve got it working but something seems off in my logs, It looks like I’m getting two lookups for every priority?


[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Reusing ODBC handle 0x7f8da8002938 from class 'odbc_kiniston-test'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM extensions-test WHERE exten = ? AND priority = ? AND context = ?
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 1 ('exten') = '5206700792'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 2 ('priority') = '5'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 3 ('context') = 'sip-in'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Releasing ODBC handle 0x7f8da8002938 into pool
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Reusing ODBC handle 0x7f8da8002938 from class 'odbc_kiniston-test'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM extensions-test WHERE exten = ? AND priority = ? AND context = ?
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 1 ('exten') = '5206700792'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 2 ('priority') = '5'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 3 ('context') = 'sip-in'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Releasing ODBC handle 0x7f8da8002938 into pool
[Oct 12 16:45:24] VERBOSE[26541][C-0000000e] pbx_realtime.c: Executing [5206700792@sip-in:5] Gosub("PJSIP/trunks1-0000000e", "sub-setupinboundcall,s,1(kiniston,Pop_Country_Crossover,300,VOIP)")

---SNIP---

[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Reusing ODBC handle 0x7f8da8002938 from class 'odbc_kiniston-test'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM extensions-test WHERE exten = ? AND priority = ? AND context = ?
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 1 ('exten') = '5206700792'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 2 ('priority') = '6'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 3 ('context') = 'sip-in'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Releasing ODBC handle 0x7f8da8002938 into pool
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Reusing ODBC handle 0x7f8da8002938 from class 'odbc_kiniston-test'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Skip: 0; SQL: SELECT * FROM extensions-test WHERE exten = ? AND priority = ? AND context = ?
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 1 ('exten') = '5206700792'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 2 ('priority') = '6'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_config_odbc.c: Parameter 3 ('context') = 'sip-in'
[Oct 12 16:45:24] DEBUG[26541][C-0000000e] res_odbc.c: Releasing ODBC handle 0x7f8da8002938 into pool
[Oct 12 16:45:24] VERBOSE[26541][C-0000000e] pbx_realtime.c: Executing [5206700792@sip-in:6] Goto("PJSIP/trunk1-0000000e", "kiniston-ivr,s,1")
[Oct 12 16:45:24] VERBOSE[26541][C-0000000e] pbx_builtins.c: Goto (kiniston-ivr,s,1)

I wasn’t expecting asterisk to do two queries for each extension and priority it’s looking up.

The contents of my table are just

id				context		exten		priority	app	appdata
7301702413361087843     sip-in	5206700792	5	Gosub	sub-setupinboundcall,s,1(kiniston,Pop_Country_Crossover,300,VOIP)
7301702413361087848	sip-in	5206700792	6	Goto	kiniston-ivr,s,1

My extensions.conf

[sip-in]
exten => _X.,1,Log(NOTICE,Incoming ${CHANNEL:0:3} call DID: ${EXTEN} from CallerID: ${CALLERID(num)} ${CALLERID(name)}, ANI:${CALLERID(ani)} ANI2:${CALLINGANI2})
exten => _X.,2,Set(ARRAY(CDR(firstext),CDR(firstcontext))=${EXTEN},${CONTEXT})
exten => _X.,3,Set(ARRAY(__FirstEXT,__FirstContext)=${EXTEN},${CONTEXT})
exten => _X.,4,Set(CHANNEL(hangup_handler_push)=cdr-fixup,s,1)
exten => _X.,7,Hangup()
switch => Realtime/sip-in@extensions/p

I haven’t used Realtime in production before so maybe this is expected behavior but I haven’t seen mention of it before.

My test environment is running Asterisk 13.12.0