问:
Docker Redis sentinel strange timeout erros
I am getting strange errors for my redis-sentinel. Anyone has any idea what is this?

```<code>2022-12-14T23:00:00.000+0000
</code>```

The timeout was reached before the message could be written to the output buffer, and it was not sent, command=PING, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Initializing, in: 0, last-in: 0, cur-in: 0, sync-ops: 1, async-ops: 8, serverEndpoint: 10.0.14.13:6379, conn-sec: n/a, mc: 1/1/0, mgr: 10 of 10 available, clientName: boydn-api-frontend(SE.Redis-v2.6.86.49666), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=5,Free=32762,Min=8,Max=32767), POOL: (Threads=16,QueuedItems=1,CompletedItems=5109581), v: 2.6.86.49666 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)

latency_percentiles_usec_echo:p50=0.001,p99=1.003,p99.9=8.031
latency_percentiles_usec_set:p50=6.015,p99=17.023,p99.9=54.015
latency_percentiles_usec_ping:p50=1.003,p99=3.007,p99.9=18.047
latency_percentiles_usec_publish:p50=10.047,p99=28.031,p99.9=86.015
latency_percentiles_usec_del:p50=4.015,p99=20.095,p99.9=96.255

Cluster

cluster_enabled:0

Keyspace

db0:keys=4,expires=4,avg_ttl=0
------ CLIENT LIST OUTPUT ------
id=218210 addr=10.0.14.43:38498 laddr=10.0.14.13:6379 fd=11 name=boydn-api-backend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=info user=default redir=-1 resp=2
id=218211 addr=10.0.14.43:38512 laddr=10.0.14.13:6379 fd=12 name=boydn-api-backend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218212 addr=10.0.14.47:51232 laddr=10.0.14.13:6379 fd=13 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218213 addr=10.0.14.45:48894 laddr=10.0.14.13:6379 fd=14 name=boydn-api-solr(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2

r=10.0.14.10:6379 laddr=10.0.14.13:46154 fd=9 name= age=93266 idle=0 flags=M db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=62 qbuf-free=40892 argv-mem=27 multi-mem=0 rbs=1024 rbp=41 obl=0 oll=0 omem=0 tot-mem=42819 events=r cmd=set user=(superuser) redir=-1 resp=2
id=218214 addr=10.0.14.45:48910 laddr=10.0.14.13:6379 fd=15 name=boydn-api-solr(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218215 addr=10.0.14.7:51498 laddr=10.0.14.13:6379 fd=16 name=sentinel-6866bc27-cmd age=1 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=7 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218216 addr=10.0.14.7:51514 laddr=10.0.14.13:6379 fd=17 name=sentinel-6866bc27-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218217 addr=10.0.14.9:36654 laddr=10.0.14.13:6379 fd=18 name=sentinel-dc4d989a-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218218 addr=10.0.14.3:41044 laddr=10.0.14.13:6379 fd=20 name=sentinel-2c433ea4-cmd age=1 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=7 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218219 addr=10.0.14.3:41048 laddr=10.0.14.13:6379 fd=21 name=sentinel-2c433ea4-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218206 addr=10.0.14.9:36628 laddr=10.0.14.13:6379 fd=19 name=sentinel-dc4d989a-cmd age=6 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=343 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218209 addr=10.0.14.47:51224 laddr=10.0.14.13:6379 fd=10 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=info user=default redir=-1 resp=2
id=218230 addr=10.0.14.47:51330 laddr=10.0.14.13:6379 fd=22 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37632 events=r cmd=info user=default redir=-1 resp=2
id=218231 addr=10.0.14.47:51332 laddr=10.0.14.13:6379 fd=23 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=0 idle=0 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37688 events=r cmd=subscribe user=default redir=-1 resp=2
------ CURRENT CLIENT INFO ------

r=10.0.14.10:6379 laddr=10.0.14.13:46154 fd=9 name= age=93266 idle=0 flags=M db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=62 qbuf-free=40892 argv-mem=27 multi-mem=0 rbs=1024 rbp=41 obl=0 oll=0 omem=0 tot-mem=42819 events=r cmd=set user=(superuser) redir=-1 resp=2
argv[0]: '"SET"'
argv[1]: '"UserId"'
argv[2]: '"4"'
argv[3]: '"PXAT"'
argv[4]: '"1671029791661"'
1:S 14 Dec 2022 14:56:01.673 # key 'UserId' found in DB containing the following object:
1:S 14 Dec 2022 14:56:01.673 # Object type: 0
1:S 14 Dec 2022 14:56:01.673 # Object encoding: 1
1:S 14 Dec 2022 14:56:01.673 # Object refcount: 2147483647
------ MODULES INFO OUTPUT ------
------ CONFIG DEBUG OUTPUT ------
sanitize-dump-payload no
list-compress-depth 0

io-threads 1
repl-diskless-load disabled
proto-max-bulk-len 512mb
lazyfree-lazy-server-del no
replica-read-only yes
activedefrag no
lazyfree-lazy-user-flush no
io-threads-do-reads no
client-query-buffer-limit 1gb
lazyfree-lazy-user-del no
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
slave-read-only yes
repl-diskless-sync yes
------ FAST MEMORY TEST ------
1:S 14 Dec 2022 14:56:01.674 # Bio thread for job type #0 terminated
1:S 14 Dec 2022 14:56:01.675 # Bio thread for job type #1 terminated
1:S 14 Dec 2022 14:56:01.675 # Bio thread for job type #2 terminated
*** Preparing to test memory region 55f083265000 (2301952 bytes)
*** Preparing to test memory region 55f08511d000 (344064 bytes)
*** Preparing to test memory region 7fc398000000 (135168 bytes)
*** Preparing to test memory region 7fc39c07f000 (22544384 bytes)
*** Preparing to test memory region 7fc39d600000 (8388608 bytes)
*** Preparing to test memory region 7fc39de00000 (2097152 bytes)
*** Preparing to test memory region 7fc39e17f000 (2621440 bytes)
*** Preparing to test memory region 7fc39e400000 (8388608 bytes)
*** Preparing to test memory region 7fc39ec00000 (2097152 bytes)
*** Preparing to test memory region 7fc39effd000 (8388608 bytes)
*** Preparing to test memory region 7fc39f7fe000 (8388608 bytes)
*** Preparing to test memory region 7fc39ffff000 (8388608 bytes)
*** Preparing to test memory region 7fc3a0800000 (8388608 bytes)
*** Preparing to test memory region 7fc3a1000000 (8388608 bytes)
*** Preparing to test memory region 7fc3a188b000 (8192 bytes)
*** Preparing to test memory region 7fc3a18a3000 (49152 bytes)
*** Preparing to test memory region 7fc3a1a80000 (16384 bytes)
*** Preparing to test memory region 7fc3a1aa2000 (16384 bytes)
*** Preparing to test memory region 7fc3a1d96000 (16384 bytes)
*** Preparing to test memory region 7fc3a1f77000 (8192 bytes)
*** Preparing to test memory region 7fc3a1fa7000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.
=== REDIS BUG REPORT END. Make sure to include from START to END. ===
Please report the crash by opening an issue on github:
http://github.com/redis/redis/issues
If a Redis module was involved, please open in the module's repo instead.
Suspect RAM error? Use redis-server --test-memory to verify it.
Some other issues could be detected by redis-server --check-system

Body:
I am getting strange errors for my redis-sentinel. Anyone has any idea what is this?

2022-12-14T23:00:00.000+0000

The timeout was reached before the message could be written to the output buffer, and it was not sent, command=PING, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Initializing, in: 0, last-in: 0, cur-in: 0, sync-ops: 1, async-ops: 8, serverEndpoint: 10.0.14.13:6379, conn-sec: n/a, mc: 1/1/0, mgr: 10 of 10 available, clientName: boydn-api-frontend(SE.Redis-v2.6.86.49666), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=5,Free=32762,Min=8,Max=32767), POOL: (Threads=16,QueuedItems=1,CompletedItems=5109581), v: 2.6.86.49666 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)

latency_percentiles_usec_echo:p50=0.001,p99=1.003,p99.9=8.031
latency_percentiles_usec_set:p50=6.015,p99=17.023,p99.9=54.015
latency_percentiles_usec_ping:p50=1.003,p99=3.007,p99.9=18.047
latency_percentiles_usec_publish:p50=10.047,p99=28.031,p99.9=86.015
latency_percentiles_usec_del:p50=4.015,p99=20.095,p99.9=96.255

Cluster

cluster_enabled:0

Keyspace

db0:keys=4,expires=4,avg_ttl=0
------ CLIENT LIST OUTPUT ------
id=218210 addr=10.0.14.43:38498 laddr=10.0.14.13:6379 fd=11 name=boydn-api-backend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=info user=default redir=-1 resp=2
id=218211 addr=10.0.14.43:38512 laddr=10.0.14.13:6379 fd=12 name=boydn-api-backend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218212 addr=10.0.14.47:51232 laddr=10.0.14.13:6379 fd=13 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218213 addr=10.0.14.45:48894 laddr=10.0.14.13:6379 fd=14 name=boydn-api-solr(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2

r=10.0.14.10:6379 laddr=10.0.14.13:46154 fd=9 name= age=93266 idle=0 flags=M db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=62 qbuf-free=40892 argv-mem=27 multi-mem=0 rbs=1024 rbp=41 obl=0 oll=0 omem=0 tot-mem=42819 events=r cmd=set user=(superuser) redir=-1 resp=2
id=218214 addr=10.0.14.45:48910 laddr=10.0.14.13:6379 fd=15 name=boydn-api-solr(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218215 addr=10.0.14.7:51498 laddr=10.0.14.13:6379 fd=16 name=sentinel-6866bc27-cmd age=1 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=7 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218216 addr=10.0.14.7:51514 laddr=10.0.14.13:6379 fd=17 name=sentinel-6866bc27-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218217 addr=10.0.14.9:36654 laddr=10.0.14.13:6379 fd=18 name=sentinel-dc4d989a-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218218 addr=10.0.14.3:41044 laddr=10.0.14.13:6379 fd=20 name=sentinel-2c433ea4-cmd age=1 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=7 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218219 addr=10.0.14.3:41048 laddr=10.0.14.13:6379 fd=21 name=sentinel-2c433ea4-pubsub age=1 idle=1 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=138 obl=0 oll=0 omem=0 tot-mem=22328 events=r cmd=subscribe user=default redir=-1 resp=2
id=218206 addr=10.0.14.9:36628 laddr=10.0.14.13:6379 fd=19 name=sentinel-dc4d989a-cmd age=6 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=343 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=ping user=default redir=-1 resp=2
id=218209 addr=10.0.14.47:51224 laddr=10.0.14.13:6379 fd=10 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=1 idle=1 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=1024 rbp=0 obl=0 oll=0 omem=0 tot-mem=22272 events=r cmd=info user=default redir=-1 resp=2
id=218230 addr=10.0.14.47:51330 laddr=10.0.14.13:6379 fd=22 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=0 idle=0 flags=N db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37632 events=r cmd=info user=default redir=-1 resp=2
id=218231 addr=10.0.14.47:51332 laddr=10.0.14.13:6379 fd=23 name=boydn-api-frontend(SE.Redis-v2.6.86.49666) age=0 idle=0 flags=P db=0 sub=1 psub=0 ssub=0 multi=-1 qbuf=0 qbuf-free=20474 argv-mem=0 multi-mem=0 rbs=16384 rbp=16384 obl=0 oll=0 omem=0 tot-mem=37688 events=r cmd=subscribe user=default redir=-1 resp=2
------ CURRENT CLIENT INFO ------

r=10.0.14.10:6379 laddr=10.0.14.13:46154 fd=9 name= age=93266 idle=0 flags=M db=0 sub=0 psub=0 ssub=0 multi=-1 qbuf=62 qbuf-free=40892 argv-mem=27 multi-mem=0 rbs=1024 rbp=41 obl=0 oll=0 omem=0 tot-mem=42819 events=r cmd=set user=(superuser) redir=-1 resp=2
argv[0]: '"SET"'
argv[1]: '"UserId"'
argv[2]: '"4"'
argv[3]: '"PXAT"'
argv[4]: '"1671029791661"'
1:S 14 Dec 2022 14:56:01.673 # key 'UserId' found in DB containing the following object:
1:S 14 Dec 2022 14:56:01.673 # Object type: 0
1:S 14 Dec 2022 14:56:01.673 # Object encoding: 1
1:S 14 Dec 2022 14:56:01.673 # Object refcount: 2147483647
------ MODULES INFO OUTPUT ------
------ CONFIG DEBUG OUTPUT ------
sanitize-dump-payload no
list-compress-depth 0

io-threads 1
repl-diskless-load disabled
proto-max-bulk-len 512mb
lazyfree-lazy-server-del no
replica-read-only yes
activedefrag no
lazyfree-lazy-user-flush no
io-threads-do-reads no
client-query-buffer-limit 1gb
lazyfree-lazy-user-del no
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
slave-read-only yes
repl-diskless-sync yes
------ FAST MEMORY TEST ------
1:S 14 Dec 2022 14:56:01.674 # Bio thread for job type #0 terminated
1:S 14 Dec 2022 14:56:01.675 # Bio thread for job type #1 terminated
1:S 14 Dec 2022 14:56:01.675 # Bio thread for job type #2 terminated
*** Preparing to test memory region 55f083265000 (2301952 bytes)
*** Preparing to test memory region 55f08511d000 (344064 bytes)
*** Preparing to test memory region 7fc398000000 (135168 bytes)
*** Preparing to test memory region 7fc39c07f000 (22544384 bytes)
*** Preparing to test memory region 7fc39d600000 (8388608 bytes)
*** Preparing to test memory region 7fc39de00000 (2097152 bytes)
*** Preparing to test memory region 7fc39e17f000 (2621440 bytes)
*** Preparing to test memory region 7fc39e400000 (8388608 bytes)
*** Preparing to test memory region 7fc39ec00000 (2097152 bytes)
*** Preparing to test memory region 7fc39effd000 (8388608 bytes)
*** Preparing to test memory region 7fc39f7fe000 (8388608 bytes)
*** Preparing to test memory region 7fc39ffff000 (8388608 bytes)
*** Preparing to test memory region 7fc3a0800000 (8388608 bytes)
*** Preparing to test memory region 7fc3a1000000 (8388608 bytes)
*** Preparing to test memory region 7fc3a188b000 (8192 bytes)
*** Preparing to test memory region 7fc3a18a3000 (49152 bytes)
*** Preparing to test memory region 7fc3a1a80000 (16384 bytes)
*** Preparing to test memory region 7fc3a1aa2000 (16384 bytes)
*** Preparing to test memory region 7fc3a1d96000 (16384 bytes)
*** Preparing to test memory region 7fc3a1f77000 (8192 bytes)
*** Preparing to test memory region 7fc3a1fa7000 (4096 bytes)
.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O
Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.
=== REDIS BUG REPORT END. Make sure to include from START to END. ===
Please report the crash by opening an issue on github:
http://github.com/redis/redis/issues
If a Redis module was involved, please open in the module's repo instead.
Suspect RAM error? Use redis-server --test-memory to verify it.
Some other issues could be detected by redis-server --check-system


来源: stackexchange

问:
Laravel - Docker - Multi stage build
I have a Laravel application that puts me in great difficulty because although the build is done successfully in the temporary frontend image (NodeJS), the application has javascript errors on certain pages.

If I install NodeJS directly in the running container and execute the same commands from the frontend, everything works perfectly.

I don't understand what can damage the application itself just by the simple fact that I build the interface in one way or another.

Any suggestion is welcome.

Thanks!

Dockerfile:

```<code># Composer
FROM composer:2 AS vendor
RUN  apk add --no-cache \
        libjpeg-turbo-dev \
        libpng-dev \
        libwebp-dev \
        freetype-dev && \
    docker-php-ext-install pcntl && \
    docker-php-ext-install gd
COPY database/ ./database/
COPY composer.json ./
RUN composer update --no-progress \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist

# NodeJS
FROM node:18-alpine as frontend
RUN mkdir -p /app
WORKDIR /app
COPY resources/ ./resources/
COPY package.json ./package.json
COPY webpack.mix.js ./webpack.mix.js
RUN npm install -g npm@latest && \
    npm install --no-progress && \
    npm run prod --no-progress

# Download base image ubuntu 22.04
FROM ubuntu:22.04

# Changing sh shell to bash
SHELL ["/bin/bash", "-c", "-o", "pipefail"]

# Copy deploy script
COPY Dockerfiles/deploy.sh /root/deploy.sh
RUN chmod +x /root/deploy.sh

# Change working directory
WORKDIR /var/www/html

### Installation of other packages irrelevant to the presented problem ###

# Here we do the magic!
COPY --from=vendor /usr/bin/composer /usr/local/bin/composer

# Move repository
COPY --chown=www-data:www-data ./ ./
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /var/www/html/vendor/
COPY --chown=www-data:www-data --from=frontend /app/public/ /var/www/html/public/

# Prepare logs folder
RUN mkdir -p -m 0777 /var/log/amqp

# Expose Port for the Application
EXPOSE 80 443

# Copy start.sh script and define default command for the container
CMD ["/usr/bin/supervisord"]

</code>```

webpack.mix.js

```<code>const mix = require('laravel-mix');
// mix.options({ purifyCss: true });
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.setPublicPath('public')
    .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .version();
</code>```

ContentLicense: CC BY-SA 4.0

Title: Laravel - Docker - Multi stage build

Body:
I have a Laravel application that puts me in great difficulty because although the build is done successfully in the temporary frontend image (NodeJS), the application has javascript errors on certain pages.

If I install NodeJS directly in the running container and execute the same commands from the frontend, everything works perfectly.

I don't understand what can damage the application itself just by the simple fact that I build the interface in one way or another.

Any suggestion is welcome.

Thanks!

Dockerfile:

# Composer
FROM composer:2 AS vendor
RUN  apk add --no-cache \
        libjpeg-turbo-dev \
        libpng-dev \
        libwebp-dev \
        freetype-dev && \
    docker-php-ext-install pcntl && \
    docker-php-ext-install gd
COPY database/ ./database/
COPY composer.json ./
RUN composer update --no-progress \
    --no-interaction \
    --no-plugins \
    --no-scripts \
    --prefer-dist

# NodeJS
FROM node:18-alpine as frontend
RUN mkdir -p /app
WORKDIR /app
COPY resources/ ./resources/
COPY package.json ./package.json
COPY webpack.mix.js ./webpack.mix.js
RUN npm install -g npm@latest && \
    npm install --no-progress && \
    npm run prod --no-progress

# Download base image ubuntu 22.04
FROM ubuntu:22.04

# Changing sh shell to bash
SHELL ["/bin/bash", "-c", "-o", "pipefail"]

# Copy deploy script
COPY Dockerfiles/deploy.sh /root/deploy.sh
RUN chmod +x /root/deploy.sh

# Change working directory
WORKDIR /var/www/html

### Installation of other packages irrelevant to the presented problem ###

# Here we do the magic!
COPY --from=vendor /usr/bin/composer /usr/local/bin/composer

# Move repository
COPY --chown=www-data:www-data ./ ./
COPY --chown=www-data:www-data --from=vendor /app/vendor/ /var/www/html/vendor/
COPY --chown=www-data:www-data --from=frontend /app/public/ /var/www/html/public/

# Prepare logs folder
RUN mkdir -p -m 0777 /var/log/amqp

# Expose Port for the Application
EXPOSE 80 443

# Copy start.sh script and define default command for the container
CMD ["/usr/bin/supervisord"]

webpack.mix.js

const mix = require('laravel-mix');
// mix.options({ purifyCss: true });
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.setPublicPath('public')
    .js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css')
    .version();


问:
Javascript math with numbers that are too big for BigInt
I was unable to solve part 2 of day 11 of advent of code this year because I couldn't figure out how to handle extremely large numbers in javascript. Here is the code I used:

import { join } from 'path';
import { open } from 'fs/promises';

let monkies: Monkey[] = [];

type MonkeyArgs = {
  items: bigint[];
  operation: (old: bigint) => bigint;
  testNum: number;
  testTrueMonkey: number;
  testFalseMonkey: number;
};

class Monkey {
  items: bigint[];
  operation: (old: bigint) => bigint;
  throw: (item: bigint) => void;

  constructor({
    items,
    operation,
    testNum,
    testTrueMonkey,
    testFalseMonkey,
  }: MonkeyArgs) {
    this.items = items;
    this.operation = operation;
    this.throw = (item: bigint) => {
      if (item % BigInt(testNum) === BigInt(0)) {
        monkies[testTrueMonkey].items.push(item);
      } else {
        monkies[testFalseMonkey].items.push(item);
      }
    };
  }
}

const itemsRegex = /Starting items: ((?:\d+(?:, )?)+)/;
const operationRegex = /Operation: new = old (\*|\+) (\d+|old)/;
const testRegex = /Test: divisible by (\d+)/;
const testTrueRegex = /If true: throw to monkey (\d+)/;
const testFalseRegex = /If false: throw to monkey (\d+)/;

const initializeMonkies = async () => {
  monkies = [];
  const file = await open(join('11', 'input.txt'));

  let args: Partial<MonkeyArgs> = {};
  for await (const line of file.readLines()) {
    if (itemsRegex.test(line)) {
      const itemsMatch = line.match(itemsRegex)!;
      const items = itemsMatch[1]
        .split(', ')
        .map((item) => BigInt(parseInt(item, 10)));
      args.items = items;
    }

    if (operationRegex.test(line)) {
      const operationMatch = line.match(operationRegex)!;
      const num = parseInt(operationMatch[2], 10);

      args.operation = (old) =>
        operationMatch[1] === '+'
          ? old + (isNaN(num) ? old : BigInt(num))
          : old * (isNaN(num) ? old : BigInt(num));
    }

    if (testRegex.test(line)) {
      const testMatch = line.match(testRegex)!;

      args.testNum = parseInt(testMatch[1], 10);
    }

    if (testTrueRegex.test(line)) {
      const testTrueMatch = line.match(testTrueRegex)!;

      args.testTrueMonkey = parseInt(testTrueMatch[1], 10);
    }

    if (testFalseRegex.test(line)) {
      const testFalseMatch = line.match(testFalseRegex)!;

      args.testFalseMonkey = parseInt(testFalseMatch[1], 10);

      const monkey = new Monkey(args as MonkeyArgs);
      monkies.push(monkey);

      args = {};
    }
  }
};

const calculateMonkeyBusiness = async ({
  rounds,
  shouldDivideWorryLevel,
}: {
  rounds: number;
  shouldDivideWorryLevel: boolean;
}) => {
  await initializeMonkies();

  const inspections = [...Array(monkies.length).keys()].map(() => 0);

  for (let round = 0; round < rounds; ++round) {
    console.log(`Doing round ${round + 1}`);
    monkies.forEach((monkey, i) => {
      monkey.items.forEach((item, j) => {
        ++inspections[i];
        let itemToThrow = item;
        itemToThrow = monkey.operation(itemToThrow);

        if (shouldDivideWorryLevel) {
          itemToThrow = itemToThrow / BigInt(3);
        }

        monkey.throw(itemToThrow);
      });

      monkey.items = [];
    });
  }

  return [...inspections]
    .sort((a, b) => a - b)
    .slice(-2)
    .reduce((acc, cur) => cur * acc, 1);
};

const solution = async ({
  rounds,
  shouldDivideWorryLevel,
}: {
  rounds: number;
  shouldDivideWorryLevel: boolean;
}) => {
  console.log('Calculating monkey business');

  console.log(
    `Monkey business level after ${rounds} rounds is ${await calculateMonkeyBusiness(
      {
        rounds,
        shouldDivideWorryLevel,
      }
    )}`
  );
};

export const solution1 = async () =>
  await solution({ rounds: 20, shouldDivideWorryLevel: true });

export const solution2 = async () =>
  await solution({ rounds: 10000, shouldDivideWorryLevel: false });
```
<p>Notice that I'm using <code>BigInt</code>. When running <code>solution2</code>, which has a loop that iterates 10000 times, the program starts to get incredibly slow around the 300th iteration. When it reaches the 364th iteration, it crashes with the following error message:</p>
```/home/abias/projects/advent-of-code/2022/11/solution.ts:65
          : old * (isNaN(num) ? old : BigInt(num));
               ^
RangeError: Maximum BigInt size exceeded
    at Monkey.args.operation (/home/abias/projects/advent-of-code/2022/11/solution.ts:65:16)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:110:30
    at Array.forEach (<anonymous>)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:107:20
    at Array.forEach (<anonymous>)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:106:13
    at Generator.next (<anonymous>)
    at fulfilled (/home/abias/projects/advent-of-code/2022/11/solution.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
```

It seems the numbers got too big for BigInt. How do I handle numbers that big?

Body:
I was unable to solve part 2 of day 11 of advent of code this year because I couldn't figure out how to handle extremely large numbers in javascript. Here is the code I used:

import { join } from 'path';
import { open } from 'fs/promises';

let monkies: Monkey[] = [];

type MonkeyArgs = {
  items: bigint[];
  operation: (old: bigint) => bigint;
  testNum: number;
  testTrueMonkey: number;
  testFalseMonkey: number;
};

class Monkey {
  items: bigint[];
  operation: (old: bigint) => bigint;
  throw: (item: bigint) => void;

  constructor({
    items,
    operation,
    testNum,
    testTrueMonkey,
    testFalseMonkey,
  }: MonkeyArgs) {
    this.items = items;
    this.operation = operation;
    this.throw = (item: bigint) => {
      if (item % BigInt(testNum) === BigInt(0)) {
        monkies[testTrueMonkey].items.push(item);
      } else {
        monkies[testFalseMonkey].items.push(item);
      }
    };
  }
}

const itemsRegex = /Starting items: ((?:\d+(?:, )?)+)/;
const operationRegex = /Operation: new = old (\*|\+) (\d+|old)/;
const testRegex = /Test: divisible by (\d+)/;
const testTrueRegex = /If true: throw to monkey (\d+)/;
const testFalseRegex = /If false: throw to monkey (\d+)/;

const initializeMonkies = async () => {
  monkies = [];
  const file = await open(join('11', 'input.txt'));

  let args: Partial<MonkeyArgs> = {};
  for await (const line of file.readLines()) {
    if (itemsRegex.test(line)) {
      const itemsMatch = line.match(itemsRegex)!;
      const items = itemsMatch[1]
        .split(', ')
        .map((item) => BigInt(parseInt(item, 10)));
      args.items = items;
    }

    if (operationRegex.test(line)) {
      const operationMatch = line.match(operationRegex)!;
      const num = parseInt(operationMatch[2], 10);

      args.operation = (old) =>
        operationMatch[1] === '+'
          ? old + (isNaN(num) ? old : BigInt(num))
          : old * (isNaN(num) ? old : BigInt(num));
    }

    if (testRegex.test(line)) {
      const testMatch = line.match(testRegex)!;

      args.testNum = parseInt(testMatch[1], 10);
    }

    if (testTrueRegex.test(line)) {
      const testTrueMatch = line.match(testTrueRegex)!;

      args.testTrueMonkey = parseInt(testTrueMatch[1], 10);
    }

    if (testFalseRegex.test(line)) {
      const testFalseMatch = line.match(testFalseRegex)!;

      args.testFalseMonkey = parseInt(testFalseMatch[1], 10);

      const monkey = new Monkey(args as MonkeyArgs);
      monkies.push(monkey);

      args = {};
    }
  }
};

const calculateMonkeyBusiness = async ({
  rounds,
  shouldDivideWorryLevel,
}: {
  rounds: number;
  shouldDivideWorryLevel: boolean;
}) => {
  await initializeMonkies();

  const inspections = [...Array(monkies.length).keys()].map(() => 0);

  for (let round = 0; round < rounds; ++round) {
    console.log(`Doing round ${round + 1}`);
    monkies.forEach((monkey, i) => {
      monkey.items.forEach((item, j) => {
        ++inspections[i];
        let itemToThrow = item;
        itemToThrow = monkey.operation(itemToThrow);

        if (shouldDivideWorryLevel) {
          itemToThrow = itemToThrow / BigInt(3);
        }

        monkey.throw(itemToThrow);
      });

      monkey.items = [];
    });
  }

  return [...inspections]
    .sort((a, b) => a - b)
    .slice(-2)
    .reduce((acc, cur) => cur * acc, 1);
};

const solution = async ({
  rounds,
  shouldDivideWorryLevel,
}: {
  rounds: number;
  shouldDivideWorryLevel: boolean;
}) => {
  console.log('Calculating monkey business');

  console.log(
    `Monkey business level after ${rounds} rounds is ${await calculateMonkeyBusiness(
      {
        rounds,
        shouldDivideWorryLevel,
      }
    )}`
  );
};

export const solution1 = async () =>
  await solution({ rounds: 20, shouldDivideWorryLevel: true });

export const solution2 = async () =>
  await solution({ rounds: 10000, shouldDivideWorryLevel: false });

Notice that I'm using BigInt. When running solution2, which has a loop that iterates 10000 times, the program starts to get incredibly slow around the 300th iteration. When it reaches the 364th iteration, it crashes with the following error message:

/home/abias/projects/advent-of-code/2022/11/solution.ts:65
          : old * (isNaN(num) ? old : BigInt(num));
               ^
RangeError: Maximum BigInt size exceeded
    at Monkey.args.operation (/home/abias/projects/advent-of-code/2022/11/solution.ts:65:16)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:110:30
    at Array.forEach (<anonymous>)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:107:20
    at Array.forEach (<anonymous>)
    at /home/abias/projects/advent-of-code/2022/11/solution.ts:106:13
    at Generator.next (<anonymous>)
    at fulfilled (/home/abias/projects/advent-of-code/2022/11/solution.ts:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

It seems the numbers got too big for BigInt. How do I handle numbers that big?


问:
How to do single page selection?
I place the data in the jQuery DataTables Library
A built-in display of several data on one page (there are four choices of 10, 25, 50, and 100 pages).

I have a checkbox for each item of data.
How to select a single page all checkbox?

At the beginning, I just want to press the next page to select all the checkboxes on the entire page, but the number of strokes per page can be adjusted (10, 25, 50, 100), so it cannot be completed.

I use Vue2 to do select all.

I am looking to check all checkboxes on a single page

Even if I select the next page and adjust the number of strokes to 50, I can still select 50 strokes on this page

Title: How to do single page selection?


问:
RTSP Frame Timestamp - Python
System:

[Stream 1] Camera Streaming RTSP to AI Module

AI Module writes JSON to Database (With Timestamp)

[Stream 2] Camera Streaming RTSP to Video Recorder

Video Recorder is accessed for Post Analysis

Scenario:

I want to be able to join the JSON message with the output from Video Recorder for Post analysis

Time Drift is observed between the three systems: Camera, AI Module and Video Recorder

Question:

Does RTSP stream contain unique Identifier that distinguish the frames?

Is there a way to match the JSON messages' frame to Video Recorder's Frame when doing Post Analysis?

Title: RTSP Frame Timestamp - Python


问:
Annotation to bind custom property source in spring
How can I pass the custom created property source dbProps to @PropertySource annotation or is there any way to bind the dbProps with a class like how we used to do with other properties file placed in classpath ?


问:
Connection failed to HTTP handler for endpoint. Maximo escalation error
Due to a migration of Maximo in our environment to a new version, all scripts running the httplib had to be changed to use httphandler as httplib doesn't work with the new Maximo version, including one of my scripts. Now, after implementing this change, sometimes the script doesn't run properly giving the error mentioned in the title.

Previous function (httplib):

```<code>#   Function:       httpDiscovery   -   Performs an http-action and returns a number of http related values (responseStatus, responseReason, responseBody)
#   Parameter(s):   platform        -   String defining the platform
#                   fqdn            -   Fully Qualified Domain Name of CI
def httpDiscovery(platform, fqdn):
    try:
        # log start
        log.debug(strScriptName + " - Function:httpDiscovery(Platform: "+ platform +", FQDN: "+ fqdn +") - Start")

        # System properties Object
        sysProp = getSystemProperties(platform,fqdn)

        # Profile for TADDM discovery
        profile = sysProp.profile

        # Fetch HTTP related content
        enableScan = readProperties(sysProp.enableScanProperties)
        host = readProperties(sysProp.hostProperties)
        hostpad = readProperties(sysProp.hostpadProperties)
        base64 = readProperties(sysProp.base64Properties)
        protocol = readProperties(sysProp.protocolProperties)

        httpConnection = None

        if enableScan.lower() == "true":

            # Build the headers for the REST call
            headers = { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Basic " + base64 }

            # Instantiate HTTP connection
            httpConnection = httplib.HTTPSConnection(host)
            httpConnection.request("POST",hostpad + "?profile=" + sysProp.profile + "&scope=" + fqdn,"body=None",headers)

            # Fetch response
            response = httpConnection.getresponse()
            responseStatus = str(response.status)
            responseReason = str(response.reason)
            responseBody = response.read()

            if responseStatus.startswith("4") or responseStatus.startswith("5"):
                log.error(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
            else:
                log.info(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
                log.debug(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")

        else:
            log.debug(strScriptName + " - Function:httpDiscovery(platform,fqdn) - enableScan: " + enableScan)
    except Exception, err:
        log.error(strScriptName + " - Function:httpDiscovery(platform,fqdn) - Exception: " + str(err) + " Platform: " + platform + " FQDN: " + fqdn)
# End of function httpDiscovery(platform,fqdn)
</code>```

Current function (httphandler):

```<code>#   Function:       httpDiscovery   -   Performs an http-action and returns a number of http related values (responseStatus, responseReason, responseBody)
#   Parameter(s):   platform        -   String defining the platform
#                   fqdn            -   Fully Qualified Domain Name of CI
def httpDiscovery(platform, fqdn):
    try:
        # log start
        log.debug(strScriptName + " - Function:httpDiscovery(Platform: "+ platform +", FQDN: "+ fqdn +") - Start")

        # System properties Object
        sysProp = getSystemProperties(platform,fqdn)

        # Profile for TADDM discovery
        profile = sysProp.profile

        # Fetch HTTP related content
        enableScan = readProperties(sysProp.enableScanProperties)
        host = readProperties(sysProp.hostProperties)
        hostpad = readProperties(sysProp.hostpadProperties)
        base64 = readProperties(sysProp.base64Properties)
        protocol = readProperties(sysProp.protocolProperties)

        httpConnection = None

        if enableScan.lower() == "true":

            # Instantiate variables
            httpConnection = HTTPHandler()
            responseHeadersMap = HashMap()
            metaData = HashMap()

            # Populate header dictionary
            headerPropertiesDictionary = {}
            headerPropertiesDictionary["Accept"] = "application/json"
            headerPropertiesDictionary["Content-Type"] = "application/json"
            headerPropertiesDictionary["Authorization"] = "Basic " + base64

            # Populate header map based on above dictionary
            headerPropertiesMap = HashMap()
            for strDictKey, strDictVal in headerPropertiesDictionary.items():
                headerPropertiesMap.put(strDictKey, strDictVal)

            # Build API call
            metaData.put("URL", "https://" + host + hostpad + "?profile=" + sysProp.profile + "&scope=" + fqdn)
            metaData.put("HTTPMETHOD", "POST")
            metaData.put("HEADERPROPS", headerPropertiesMap)
            metaData.put("ERRORONSTATUS", False)
            metaData.put("RESPONSE_HEADERS",responseHeadersMap)

            # Fetch response
            response = httpConnection.invoke(metaData, None)
            responseHeaders = metaData.get("RESPONSE_HEADERS")
            responseStatus = str(responseHeaders.get("RESPONSE_STATUS"))
            responseReason = str(responseHeaders.get("RESPONSE_STATUS_TEXT"))

            # Get TADDM API response message
            if (response is not None):
                stringFResponseData = String(response, "utf-8")
                responseBody = str(stringFResponseData)
            else:
                responseBody = str(None)

            if responseStatus.startswith("4") or responseStatus.startswith("5"):
                log.error(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
            else:
                log.info(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
                log.debug(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")

        else:
            log.debug(strScriptName + " - Function:httpDiscovery(platform,fqdn) - enableScan: " + enableScan)
    except Exception, err:
        log.error(strScriptName + " - Function:httpDiscovery(platform,fqdn) - Exception: " + str(err) + " Platform: " + platform + " FQDN: " + fqdn)
# End of function httpDiscovery(platform,fqdn)
</code>```

In the previous version, whenever an error occured, it would log this, either because the error happened serverside (e.g 404) or the error happened in the script (exception). The exception looked like this previously:

```<code>[12/5/22 4:36:31:544 CET] 000001be SystemOut     O 05 Dec 2022 04:36:31:544 [ERROR] [APP_XXXXX_CRON_O1_01] [CID-MXSCRIPT-1415432] MANAGED_DISCOVERY_07 - Function:httpDiscovery(platform,fqdn) - Exception: (55, 'Software caused connection abort') Platform: XXX FQDN: XXX
</code>```

In the new function, the following error occurs:

```<code>[12/15/22 7:28:24:613 CET] 0000014f SystemOut     O 15 Dec 2022 07:28:24:613 [ERROR] [APP_XXXXX_CRON_O1_01] [] Failed to execute action  on escalation: {MY_ESCALATION} reference point: {1.269}  for object {CI} with id {1439683}
psdi.util.MXApplicationException: BMXAA7837E - An error occured that prevented the MANAGED_DISCOVERY_07 script for the MANDISCTAD launch point from running.
    psdi.util.MXSystemException: psdi.util.MXSystemException: BMXAA1477E - The connection failed to the HTTP handler for the endpoint.
</code>```

This error is not happening within the bounds of my script, and it seems to prevent the script from running at all. The code BMXAA7837E seems to be an Maximo related error. In both functions, all calls are send to a load balancer, which redirects the traffic to either one of the four servers we have. This script runs per CI, meaning, for 5000 CI's, it runs (and sends one call) 5000 times. For every 5000 runs, about 100 fail (and give this error) while the other 4900 run just fine (script works, no errors).

Why do I get this error (1) and if it is script related, should it not be logged the same as the old function (2)? Thanks

Body:
Due to a migration of Maximo in our environment to a new version, all scripts running the httplib had to be changed to use httphandler as httplib doesn't work with the new Maximo version, including one of my scripts. Now, after implementing this change, sometimes the script doesn't run properly giving the error mentioned in the title.

Previous function (httplib):

#   Function:       httpDiscovery   -   Performs an http-action and returns a number of http related values (responseStatus, responseReason, responseBody)
#   Parameter(s):   platform        -   String defining the platform
#                   fqdn            -   Fully Qualified Domain Name of CI
def httpDiscovery(platform, fqdn):
    try:
        # log start
        log.debug(strScriptName + " - Function:httpDiscovery(Platform: "+ platform +", FQDN: "+ fqdn +") - Start")

        # System properties Object
        sysProp = getSystemProperties(platform,fqdn)

        # Profile for TADDM discovery
        profile = sysProp.profile

        # Fetch HTTP related content
        enableScan = readProperties(sysProp.enableScanProperties)
        host = readProperties(sysProp.hostProperties)
        hostpad = readProperties(sysProp.hostpadProperties)
        base64 = readProperties(sysProp.base64Properties)
        protocol = readProperties(sysProp.protocolProperties)

        httpConnection = None

        if enableScan.lower() == "true":

            # Build the headers for the REST call
            headers = { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Basic " + base64 }

            # Instantiate HTTP connection
            httpConnection = httplib.HTTPSConnection(host)
            httpConnection.request("POST",hostpad + "?profile=" + sysProp.profile + "&scope=" + fqdn,"body=None",headers)

            # Fetch response
            response = httpConnection.getresponse()
            responseStatus = str(response.status)
            responseReason = str(response.reason)
            responseBody = response.read()

            if responseStatus.startswith("4") or responseStatus.startswith("5"):
                log.error(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
            else:
                log.info(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
                log.debug(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")

        else:
            log.debug(strScriptName + " - Function:httpDiscovery(platform,fqdn) - enableScan: " + enableScan)
    except Exception, err:
        log.error(strScriptName + " - Function:httpDiscovery(platform,fqdn) - Exception: " + str(err) + " Platform: " + platform + " FQDN: " + fqdn)
# End of function httpDiscovery(platform,fqdn)

Current function (httphandler):

#   Function:       httpDiscovery   -   Performs an http-action and returns a number of http related values (responseStatus, responseReason, responseBody)
#   Parameter(s):   platform        -   String defining the platform
#                   fqdn            -   Fully Qualified Domain Name of CI
def httpDiscovery(platform, fqdn):
    try:
        # log start
        log.debug(strScriptName + " - Function:httpDiscovery(Platform: "+ platform +", FQDN: "+ fqdn +") - Start")

        # System properties Object
        sysProp = getSystemProperties(platform,fqdn)

        # Profile for TADDM discovery
        profile = sysProp.profile

        # Fetch HTTP related content
        enableScan = readProperties(sysProp.enableScanProperties)
        host = readProperties(sysProp.hostProperties)
        hostpad = readProperties(sysProp.hostpadProperties)
        base64 = readProperties(sysProp.base64Properties)
        protocol = readProperties(sysProp.protocolProperties)

        httpConnection = None

        if enableScan.lower() == "true":

            # Instantiate variables
            httpConnection = HTTPHandler()
            responseHeadersMap = HashMap()
            metaData = HashMap()

            # Populate header dictionary
            headerPropertiesDictionary = {}
            headerPropertiesDictionary["Accept"] = "application/json"
            headerPropertiesDictionary["Content-Type"] = "application/json"
            headerPropertiesDictionary["Authorization"] = "Basic " + base64

            # Populate header map based on above dictionary
            headerPropertiesMap = HashMap()
            for strDictKey, strDictVal in headerPropertiesDictionary.items():
                headerPropertiesMap.put(strDictKey, strDictVal)

            # Build API call
            metaData.put("URL", "https://" + host + hostpad + "?profile=" + sysProp.profile + "&scope=" + fqdn)
            metaData.put("HTTPMETHOD", "POST")
            metaData.put("HEADERPROPS", headerPropertiesMap)
            metaData.put("ERRORONSTATUS", False)
            metaData.put("RESPONSE_HEADERS",responseHeadersMap)

            # Fetch response
            response = httpConnection.invoke(metaData, None)
            responseHeaders = metaData.get("RESPONSE_HEADERS")
            responseStatus = str(responseHeaders.get("RESPONSE_STATUS"))
            responseReason = str(responseHeaders.get("RESPONSE_STATUS_TEXT"))

            # Get TADDM API response message
            if (response is not None):
                stringFResponseData = String(response, "utf-8")
                responseBody = str(stringFResponseData)
            else:
                responseBody = str(None)

            if responseStatus.startswith("4") or responseStatus.startswith("5"):
                log.error(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
            else:
                log.info(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")
                log.debug(strScriptName + " - Function:httpDiscovery(" + "POST" + ", " + protocol + ", " + host + ", " + hostpad + ", BASE64ENC(USER:PASSWORD)) Profile = "+ sysProp.profile +" - Scope = "+ fqdn +" - End - Result(strResponseStatus, stResponseReason, strResponseData)=([" + responseStatus + "], [" + responseReason + "], [" + responseBody + "])")

        else:
            log.debug(strScriptName + " - Function:httpDiscovery(platform,fqdn) - enableScan: " + enableScan)
    except Exception, err:
        log.error(strScriptName + " - Function:httpDiscovery(platform,fqdn) - Exception: " + str(err) + " Platform: " + platform + " FQDN: " + fqdn)
# End of function httpDiscovery(platform,fqdn)

In the previous version, whenever an error occured, it would log this, either because the error happened serverside (e.g 404) or the error happened in the script (exception). The exception looked like this previously:

[12/5/22 4:36:31:544 CET] 000001be SystemOut     O 05 Dec 2022 04:36:31:544 [ERROR] [APP_XXXXX_CRON_O1_01] [CID-MXSCRIPT-1415432] MANAGED_DISCOVERY_07 - Function:httpDiscovery(platform,fqdn) - Exception: (55, 'Software caused connection abort') Platform: XXX FQDN: XXX

In the new function, the following error occurs:

[12/15/22 7:28:24:613 CET] 0000014f SystemOut     O 15 Dec 2022 07:28:24:613 [ERROR] [APP_XXXXX_CRON_O1_01] [] Failed to execute action  on escalation: {MY_ESCALATION} reference point: {1.269}  for object {CI} with id {1439683}
psdi.util.MXApplicationException: BMXAA7837E - An error occured that prevented the MANAGED_DISCOVERY_07 script for the MANDISCTAD launch point from running.
    psdi.util.MXSystemException: psdi.util.MXSystemException: BMXAA1477E - The connection failed to the HTTP handler for the endpoint.

This error is not happening within the bounds of my script, and it seems to prevent the script from running at all. The code BMXAA7837E seems to be an Maximo related error. In both functions, all calls are send to a load balancer, which redirects the traffic to either one of the four servers we have. This script runs per CI, meaning, for 5000 CI's, it runs (and sends one call) 5000 times. For every 5000 runs, about 100 fail (and give this error) while the other 4900 run just fine (script works, no errors).

Why do I get this error (1) and if it is script related, should it not be logged the same as the old function (2)? Thanks


问:
Email is not being sent
php email is not being sent
My Files: config.php, login.php, register.php, reset-password.php, verefication.php
A registration email should be sent when registering

I want to use gmail to send emails

My code register.php:

```<code><?php

    require("config.php");

    if (!empty($_POST)) {

        $response = array(
            "error" => FALSE
        );

        $query = " SELECT 1 FROM users WHERE email = :email";

        //now lets update what :user should be
        $query_params = array(
            ':email' => $_POST['email']
        );

        try {
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }

        catch (PDOException $ex) {

            $response["error"] = TRUE;
            $response["message"] = $ex->getMessage();
            die(json_encode($response));
        }

        $row = $stmt->fetch();

        if ($row) {

            $response["error"] = TRUE;
            $response["message"] = "I'm sorry, this email is already in use";
            die(json_encode($response));

        } else {

            $query = "INSERT INTO users ( `unique_id`, `name`, `email`, `encrypted_password`, `otp`, `created_at` )
            VALUES ( :uuid, :name, :email, :encrypted_password, :otp, NOW() )";

            $otp = rand(100000, 999999);
            $verified = 0;

            $query_params = array(
                ':uuid' => uniqid('', true),
                ':name' => $_POST['name'],
                ':email' => $_POST['email'],
                ':encrypted_password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
                ':otp' => $otp
            );

            try {
                $stmt = $db->prepare($query);
                $result = $stmt->execute($query_params);
            }

            catch (PDOException $ex) {
                $response["error"] = TRUE;
                $response["message"] = $ex->getMessage();
                die(json_encode($response));
            }

            $name = $_POST['name'];
            $email = $_POST['email'];
            $subject = "Android Learning Email Verification";
            $message = "Hello $name,\n\nVerify that you own $email.\n\nYou may be asked to enter this confirmation code:\n\n$otp\n\nRegards,\nAndroid Learning.";
            $from = "engriemusic@gmail.com";
            $headers = "From:" . $from;

            // Uncomment this line if you are using online server.
            mail($email,$subject,$message,$headers);

            $response["error"] = FALSE;
            $response["message"] = "Register successful!";
            echo json_encode($response);
        }

    } else {
        echo json_encode(array("message" => "Method not supported!"));
    }
</code>```

There was no instruction and support from the creator on the forum from where I downloaded the project
I use this function on a local server

Title: Email is not being sent

Body:
php email is not being sent
My Files: config.php, login.php, register.php, reset-password.php, verefication.php
A registration email should be sent when registering

I want to use gmail to send emails

My code register.php:

<?php

    require("config.php");

    if (!empty($_POST)) {

        $response = array(
            "error" => FALSE
        );

        $query = " SELECT 1 FROM users WHERE email = :email";

        //now lets update what :user should be
        $query_params = array(
            ':email' => $_POST['email']
        );

        try {
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }

        catch (PDOException $ex) {

            $response["error"] = TRUE;
            $response["message"] = $ex->getMessage();
            die(json_encode($response));
        }

        $row = $stmt->fetch();

        if ($row) {

            $response["error"] = TRUE;
            $response["message"] = "I'm sorry, this email is already in use";
            die(json_encode($response));

        } else {

            $query = "INSERT INTO users ( `unique_id`, `name`, `email`, `encrypted_password`, `otp`, `created_at` )
            VALUES ( :uuid, :name, :email, :encrypted_password, :otp, NOW() )";

            $otp = rand(100000, 999999);
            $verified = 0;

            $query_params = array(
                ':uuid' => uniqid('', true),
                ':name' => $_POST['name'],
                ':email' => $_POST['email'],
                ':encrypted_password' => password_hash($_POST['password'], PASSWORD_DEFAULT),
                ':otp' => $otp
            );

            try {
                $stmt = $db->prepare($query);
                $result = $stmt->execute($query_params);
            }

            catch (PDOException $ex) {
                $response["error"] = TRUE;
                $response["message"] = $ex->getMessage();
                die(json_encode($response));
            }

            $name = $_POST['name'];
            $email = $_POST['email'];
            $subject = "Android Learning Email Verification";
            $message = "Hello $name,\n\nVerify that you own $email.\n\nYou may be asked to enter this confirmation code:\n\n$otp\n\nRegards,\nAndroid Learning.";
            $from = "engriemusic@gmail.com";
            $headers = "From:" . $from;

            // Uncomment this line if you are using online server.
            mail($email,$subject,$message,$headers);

            $response["error"] = FALSE;
            $response["message"] = "Register successful!";
            echo json_encode($response);
        }

    } else {
        echo json_encode(array("message" => "Method not supported!"));
    }

There was no instruction and support from the creator on the forum from where I downloaded the project
I use this function on a local server


问:
how can I count each csv's row count given the solution I have
I have the following code which seperates my Records.CSV files to two different CSV files based on COMPID (-> a key given in a dictionary I created):
(the first 3 files): records(1) sepereated into two above(2) :

anyways, I need to count each csv individually(basically each file) for the number of rows and add it distinctly like the following:

and this is my function:

now my problem is, that I cant distinct each file to get its own length, as showed in red ( in the code ), the top line will be the same in each CSV.
how can I achieve two different lengths for two different files, given the solution I already have?
before u guys say, I know its not optimal, I add the first line with each iteration which is wrong, and its probably one of many mistakes I have rn,  but I just need a working solution for now.

edit ** code

```<code>   //Get values needed for the file's names
string chargeMonth = DateTime.Now.ToString("yyyyMM");
var fileCreationDate = DateTime.Now.ToString("yyyyMMdd");
string fileCreationTime = DateTime.Now.ToString("HHmmss");
string constVal = "MLL";
string fileType = "HIYUV-CHEVRA";

//Initiate variables
string[] values;
string header, sumRow;
string line, compId;
string inputFile = "records.CSV";

//Create a Dictionary that will have CompanyId as keys (for example 10, 1000)
Dictionary<string, System.IO.StreamWriter> outputFiles = new Dictionary<string, System.IO.StreamWriter>();
//Read from records.csv which is the complete datatable from database
using (System.IO.StreamReader file = new System.IO.StreamReader("D:\\" + inputFile, Encoding.Default))
       {
           //header line ( columns )
           header = file.ReadLine();
           //As long as line isnt null
           while ((line = file.ReadLine()) != null)
           {
               //Seperates with comma each value (total of 24 values-columns)
               values = line.Split(",".ToCharArray());
               //Gets company_Id
               compId = values[3];
               //Checks if Key doesnt contain CompanyId inside the dictionary
               if (!outputFiles.ContainsKey(compId))
               {
                   //This will be the created file's name
                   string outputFileName = constVal + "-" + fileType + "-" + (String.Format("{0:00000}", Int32.Parse(compId))) + "-" + chargeMonth + "-" + fileCreationDate + "-" + fileCreationTime + ".CSV";
                   //Adding keys/values to dictionary
                   outputFiles.Add(compId, new System.IO.StreamWriter("D:\\" + outputFileName));

                   //Getting number of lines ( records ) - execluding sumRow and Columns(headers)
                   //int rowNumberKey = System.IO.File.ReadAllLines("d:/records.csv").Length - 2;

                   //Foreach compId key ( two keys overall/2csvs overall ) -> will add the following line
                   //outputFiles[compId].WriteLine((String.Format("{0:00000}", Int32.Parse(compId))) + "," + chargeMonth + "," + fileCreationDate + "," + fileCreationTime + (String.Format("{0:00000}", rowNumberKey)) + ".CSV");
                     outputFiles[compId].WriteLine(header);

                 }
                    //Will write the line where company_id is key inside the dictionary(outputFiles)
                    outputFiles[compId].WriteLine(line);
              }
            }
            //Iterating through each key which is now a file > and closing each
            foreach (System.IO.StreamWriter outputFile in outputFiles.Values)
            {
                outputFile.Close();
            }
      }
</code>```

thanks!

Body:
I have the following code which seperates my Records.CSV files to two different CSV files based on COMPID (-> a key given in a dictionary I created):
(the first 3 files): records(1) sepereated into two above(2) :

anyways, I need to count each csv individually(basically each file) for the number of rows and add it distinctly like the following:

and this is my function:

now my problem is, that I cant distinct each file to get its own length, as showed in red ( in the code ), the top line will be the same in each CSV.
how can I achieve two different lengths for two different files, given the solution I already have?
before u guys say, I know its not optimal, I add the first line with each iteration which is wrong, and its probably one of many mistakes I have rn,  but I just need a working solution for now.

edit ** code

   //Get values needed for the file's names
string chargeMonth = DateTime.Now.ToString("yyyyMM");
var fileCreationDate = DateTime.Now.ToString("yyyyMMdd");
string fileCreationTime = DateTime.Now.ToString("HHmmss");
string constVal = "MLL";
string fileType = "HIYUV-CHEVRA";

//Initiate variables
string[] values;
string header, sumRow;
string line, compId;
string inputFile = "records.CSV";

//Create a Dictionary that will have CompanyId as keys (for example 10, 1000)
Dictionary<string, System.IO.StreamWriter> outputFiles = new Dictionary<string, System.IO.StreamWriter>();
//Read from records.csv which is the complete datatable from database
using (System.IO.StreamReader file = new System.IO.StreamReader("D:\\" + inputFile, Encoding.Default))
       {
           //header line ( columns )
           header = file.ReadLine();
           //As long as line isnt null
           while ((line = file.ReadLine()) != null)
           {
               //Seperates with comma each value (total of 24 values-columns)
               values = line.Split(",".ToCharArray());
               //Gets company_Id
               compId = values[3];
               //Checks if Key doesnt contain CompanyId inside the dictionary
               if (!outputFiles.ContainsKey(compId))
               {
                   //This will be the created file's name
                   string outputFileName = constVal + "-" + fileType + "-" + (String.Format("{0:00000}", Int32.Parse(compId))) + "-" + chargeMonth + "-" + fileCreationDate + "-" + fileCreationTime + ".CSV";
                   //Adding keys/values to dictionary
                   outputFiles.Add(compId, new System.IO.StreamWriter("D:\\" + outputFileName));

                   //Getting number of lines ( records ) - execluding sumRow and Columns(headers)
                   //int rowNumberKey = System.IO.File.ReadAllLines("d:/records.csv").Length - 2;

                   //Foreach compId key ( two keys overall/2csvs overall ) -> will add the following line
                   //outputFiles[compId].WriteLine((String.Format("{0:00000}", Int32.Parse(compId))) + "," + chargeMonth + "," + fileCreationDate + "," + fileCreationTime + (String.Format("{0:00000}", rowNumberKey)) + ".CSV");
                     outputFiles[compId].WriteLine(header);

                 }
                    //Will write the line where company_id is key inside the dictionary(outputFiles)
                    outputFiles[compId].WriteLine(line);
              }
            }
            //Iterating through each key which is now a file > and closing each
            foreach (System.IO.StreamWriter outputFile in outputFiles.Values)
            {
                outputFile.Close();
            }
      }

thanks!


问:
internal/modules/cjs/loader.js:582 throw err
I'm getting following Console Error. Error : Cannot find module

```<code>
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module 'C:\Users\User\Desktop\NodeJsProject\app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
    code: ←[32m'MODULE_NOT_FOUND'←[39m,

</code>```

requireStack: []

I try to delete node_modules and package-lock.json directory
and re-installed them again by runing npm install.

But it didn't work.

Body:
I'm getting following Console Error. Error : Cannot find module

internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module 'C:\Users\User\Desktop\NodeJsProject\app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
    code: ←[32m'MODULE_NOT_FOUND'←[39m,

requireStack: []

I try to delete node_modules and package-lock.json directory
and re-installed them again by runing npm install.

But it didn't work.


问:
SUMIFS Function in SQL - SUM() OVER (PARTITION BY ) is not working
I used the SUMIFS formula in my google sheet to sum the product cost based on Order Id and Composite Parent SKU if it is equal to SKU. However, I cannot get the result I want using SUM OVER PARTITION BY in SQL.

Here is my data:

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost

00001
SKU001

1
20
5

00001
SKU001X2

1
30

00001
SKU001
SKU001X2
2

10

What I get if using SUM OVER PARTITION BY:

```<code>
CASE WHEN Unit_Cost = 0 THEN 0
WHEN Unit_Cost > 0 AND Product_Cost > 0 THEN SUM(Product_Cost * Quantity)
ELSE SUM(Product_Cost * Quantity) OVER (PARTITION BY Order_Id, SKU) END
</code>```

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost
My_Result

00001
SKU001

1
20
5
15

00001
SKU001X2

1
30

00001
SKU001
SKU001X2
2

10
0

Here is the result that I want:

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost
My_Result

00001
SKU001

1
20
5
5

00001
SKU001X2

1
30

10

00001
SKU001
SKU001X2
2

10

Could anyone please help with this?

Thanks in advance.

Body:
I used the SUMIFS formula in my google sheet to sum the product cost based on Order Id and Composite Parent SKU if it is equal to SKU. However, I cannot get the result I want using SUM OVER PARTITION BY in SQL.

Here is my data:

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost

00001
SKU001

1
20
5

00001
SKU001X2

1
30

00001
SKU001
SKU001X2
2

10

What I get if using SUM OVER PARTITION BY:

CASE WHEN Unit_Cost = 0 THEN 0
WHEN Unit_Cost > 0 AND Product_Cost > 0 THEN SUM(Product_Cost * Quantity)
ELSE SUM(Product_Cost * Quantity) OVER (PARTITION BY Order_Id, SKU) END

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost
My_Result

00001
SKU001

1
20
5
15

00001
SKU001X2

1
30

00001
SKU001
SKU001X2
2

10
0

Here is the result that I want:

Order_Id
SKU
Composite_Parent_SKU
Quantity
Unit_Cost
Product_Cost
My_Result

00001
SKU001

1
20
5
5

00001
SKU001X2

1
30

10

00001
SKU001
SKU001X2
2

10

Could anyone please help with this?

Thanks in advance.


问:
Python Mocking: Not able to get the return value from mocked object
I am trying to write unit tests for this class using pytest & unittest.mock.

```<code>class GetDataStep:
blob_service_client_instance = BlobServiceClient

def execute(self, params: dict) -> str:
    logging.info(f"Executing Step: {self.__class__.__name__}")
    file_name = params["file_name"]
    storage_account_url = params["storage_account_url"]
    storage_account_key = params["storage_account_key"]
    container_name = params["container_name"]

    logging.info(f"Downloading {file_name}.")
    blob_service_client_instance = self.blob_service_client_instance(
        account_url=storage_account_url, credential=storage_account_key
    )

    blob_client_instance = blob_service_client_instance.get_blob_client(
        container_name, file_name, snapshot=None
    )

    try:
        blob_data = blob_client_instance.download_blob()
        data = blob_data.readall()
    except ResourceNotFoundError as rnfe:
        logging.info(f"Error: {file_name} does not exist!")
        logging.exception(rnfe)
        raise rnfe

    logging.info("File downloaded successfully")

    logging.info(f"Finished Step: {self.__class__.__name__}")
    return data.decode("utf-8")
</code>```

I want to mock the behavior where the code is actually calling the azure services. So instead of querying the blob storage, I want to mock it and return a string value for testing.
This is my test function.

```<code>@patch("azure.storage.blob.BlobServiceClient")
def test_execute(mock_blob_service_client):

    get_data_step = steps.GetDataStep()

    # Define the input parameters
    params = {
        "file_name": "test_file.csv",
        "storage_account_url": "https://testaccount.blob.core.windows.net",
        "storage_account_key": "test_key",
        "container_name": "test_container",
    }

    # Define a mock blob client that will return the expected file data
    mock_blob_client = mock_blob_service_client.return_value.get_blob_client.return_value
    mock_blob_client.download_blob.readall.decode.return_value = "1,2,3\n4,5,6"

    get_data_step.blob_service_client_instance = mock_blob_service_client

    # Execute the step
    file_data = get_data_step.execute(params)

    # Verify that the BlobServiceClient was instantiated with the correct arguments
    mock_blob_service_client.assert_called_once_with(
        account_url="https://testaccount.blob.core.windows.net",
        credential="test_key"
    )

    mock_blob_service_client.return_value.get_blob_client.assert_called_once_with(
        params['container_name'], params['file_name'], snapshot=None
    )
    print(file_data)

    assert file_data == "1,2,3\n4,5,6"

</code>```

The only problem is that the last assert statement is failing & giving me this error,

AssertionError: assert <MagicMockname='BlobServiceClient().get_blob_client().download_blob().readall().decode()' id='4851030480'> == '1,2,3\n4,5,6'

I am not able to find why it returns the mock object rather than the string. Any help would be appreciated.

Body:
I am trying to write unit tests for this class using pytest & unittest.mock.

class GetDataStep:
blob_service_client_instance = BlobServiceClient

def execute(self, params: dict) -> str:
    logging.info(f"Executing Step: {self.__class__.__name__}")
    file_name = params["file_name"]
    storage_account_url = params["storage_account_url"]
    storage_account_key = params["storage_account_key"]
    container_name = params["container_name"]

    logging.info(f"Downloading {file_name}.")
    blob_service_client_instance = self.blob_service_client_instance(
        account_url=storage_account_url, credential=storage_account_key
    )

    blob_client_instance = blob_service_client_instance.get_blob_client(
        container_name, file_name, snapshot=None
    )

    try:
        blob_data = blob_client_instance.download_blob()
        data = blob_data.readall()
    except ResourceNotFoundError as rnfe:
        logging.info(f"Error: {file_name} does not exist!")
        logging.exception(rnfe)
        raise rnfe

    logging.info("File downloaded successfully")

    logging.info(f"Finished Step: {self.__class__.__name__}")
    return data.decode("utf-8")

I want to mock the behavior where the code is actually calling the azure services. So instead of querying the blob storage, I want to mock it and return a string value for testing.
This is my test function.

@patch("azure.storage.blob.BlobServiceClient")
def test_execute(mock_blob_service_client):

    get_data_step = steps.GetDataStep()

    # Define the input parameters
    params = {
        "file_name": "test_file.csv",
        "storage_account_url": "https://testaccount.blob.core.windows.net",
        "storage_account_key": "test_key",
        "container_name": "test_container",
    }

    # Define a mock blob client that will return the expected file data
    mock_blob_client = mock_blob_service_client.return_value.get_blob_client.return_value
    mock_blob_client.download_blob.readall.decode.return_value = "1,2,3\n4,5,6"

    get_data_step.blob_service_client_instance = mock_blob_service_client

    # Execute the step
    file_data = get_data_step.execute(params)

    # Verify that the BlobServiceClient was instantiated with the correct arguments
    mock_blob_service_client.assert_called_once_with(
        account_url="https://testaccount.blob.core.windows.net",
        credential="test_key"
    )

    mock_blob_service_client.return_value.get_blob_client.assert_called_once_with(
        params['container_name'], params['file_name'], snapshot=None
    )
    print(file_data)

    assert file_data == "1,2,3\n4,5,6"

The only problem is that the last assert statement is failing & giving me this error,

AssertionError: assert <MagicMockname='BlobServiceClient().get_blob_client().download_blob().readall().decode()' id='4851030480'> == '1,2,3\n4,5,6'

I am not able to find why it returns the mock object rather than the string. Any help would be appreciated.


问:
Rasterio Timeout When Opening File From S3
I have a script using Rasterio which I am trying to make run faster by using multiple processing. There is a section where each process opens a file directly from S3. When I run on a server with 2 cores, this is fine, but when I run on a server with 16 cores, the program timeouts with this error:

```<code>rasterio.errors.RasterioIOError: Connection timed out after 1001 milliseconds
</code>```

This suggests that multiple processes trying to open the same file directly from S3 is causing some sort of delay, which doesn't seem right as they are only reading from the file rather and each process should be unaffected by the others.

Could this be whats causing the timeout or could it be something else? Is there a way to increase the timeout for that? I haven't seen anything online to suggest that's the case.

Body:
I have a script using Rasterio which I am trying to make run faster by using multiple processing. There is a section where each process opens a file directly from S3. When I run on a server with 2 cores, this is fine, but when I run on a server with 16 cores, the program timeouts with this error:

rasterio.errors.RasterioIOError: Connection timed out after 1001 milliseconds

This suggests that multiple processes trying to open the same file directly from S3 is causing some sort of delay, which doesn't seem right as they are only reading from the file rather and each process should be unaffected by the others.

Could this be whats causing the timeout or could it be something else? Is there a way to increase the timeout for that? I haven't seen anything online to suggest that's the case.


问:
Using input data as a second label for model training metrics in TensorFlow 2
I have made a modified version of the translator provided in the tensorflow tutorials (https://www.tensorflow.org/text/tutorials/transformer#set_up_the_loss_and_metrics). I am using the tutorial for making a decoding tool. The model takes as input a sequence of tokens and then tries to predict an output sequence of tokens that is used to encode the input tokens. (You can always explicitly decode the predicted token into the input token but not the other way as there are multiple possible prediction tokens that encode the same input token. Hence, the machine learning approach.)

It already is trainable but I would like to have a metric of the fidelity of the prediction so that I could follow how often, if ever, the model predicts a completely wrong token that decodes a wrong input token. The model should be able to get this secondary accuracy to 100% or at least very very close to it.

How should I do the conversion from prediction back to input inside the custom loss function in this case?

It would also be a bit cleaner if there is was way to use the the input data directly as a secondary label for the loss function.

I have tried to add another loss function for use in model.compile:

```<code>def masked_accuracy_2(label, pred):
  # model prediction
  pred = tf.argmax(pred, axis=2)
  # from vector representation to tokens
  pred = label_id_to_token(pred)
  # From prediction to input tokens
  pred = decode(pred)
  # Back to vectors
  pred = input_to_id(pred)

  label = tf.cast(label, pred.dtype)
  label = label_id_to_token(label)
  label = decode(label)
  label = input_2_id(pred)
  match = label == pred

  mask = label != 0

  match = match & mask

  match = tf.cast(match, dtype=tf.float32)
  mask = tf.cast(mask, dtype=tf.float32)
  return tf.reduce_sum(match)/tf.reduce_sum(mask)

</code>```

When running model.fit, I get this error:

```<code>NotImplementedError: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1291, in train_function  *
        outputs = step_function(self, iterator)
    File "<ipython-input-65-84c451711e90>", line 31, in masked_accuracy_2 *
        pred = label_id_to_token(pred)
    File "<ipython-input-13-0c7c54396a6d>", line 2, in label_id_to_token  *
        return [id2output[str(key)] for key in np.array(result)]

    NotImplementedError: Cannot convert a symbolic tf.Tensor (ArgMax_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported.
</code>```

If I iterate over the result in label_id_to_token function without np.array

```<code>def label_id_to_token(result):
  # Uses dict id2output
  return [id2output[str(key)] for key in result]
</code>```

I get an error:

```<code>
ValueError: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1290, in train_function  *
        for _ in tf.range(self._steps_per_execution):

    ValueError: 'outputs' must be defined before the loop
    Note: AutoGraph tried to define it automatically, but ran into a OperatorNotAllowedInGraphError: in user code:

        File "<ipython-input-70-7e2d0a74e115>", line 31, in masked_accuracy2  *
            pred = decode(pred)
        File "<ipython-input-62-9a80429dbc49>", line 2, in label_id_to_token  *
            return [id2output[str(key)] for key in result]

        OperatorNotAllowedInGraphError: Iterating over a symbolic `tf.Tensor` is not allowed: AutoGraph did convert this function. This might indicate you are trying to use an unsupported feature.

</code>```

Body:
I have made a modified version of the translator provided in the tensorflow tutorials (https://www.tensorflow.org/text/tutorials/transformer#set_up_the_loss_and_metrics). I am using the tutorial for making a decoding tool. The model takes as input a sequence of tokens and then tries to predict an output sequence of tokens that is used to encode the input tokens. (You can always explicitly decode the predicted token into the input token but not the other way as there are multiple possible prediction tokens that encode the same input token. Hence, the machine learning approach.)

It already is trainable but I would like to have a metric of the fidelity of the prediction so that I could follow how often, if ever, the model predicts a completely wrong token that decodes a wrong input token. The model should be able to get this secondary accuracy to 100% or at least very very close to it.

How should I do the conversion from prediction back to input inside the custom loss function in this case?

It would also be a bit cleaner if there is was way to use the the input data directly as a secondary label for the loss function.

I have tried to add another loss function for use in model.compile:

def masked_accuracy_2(label, pred):
  # model prediction
  pred = tf.argmax(pred, axis=2)
  # from vector representation to tokens
  pred = label_id_to_token(pred)
  # From prediction to input tokens
  pred = decode(pred)
  # Back to vectors
  pred = input_to_id(pred)

  label = tf.cast(label, pred.dtype)
  label = label_id_to_token(label)
  label = decode(label)
  label = input_2_id(pred)
  match = label == pred

  mask = label != 0

  match = match & mask

  match = tf.cast(match, dtype=tf.float32)
  mask = tf.cast(mask, dtype=tf.float32)
  return tf.reduce_sum(match)/tf.reduce_sum(mask)

When running model.fit, I get this error:

NotImplementedError: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1291, in train_function  *
        outputs = step_function(self, iterator)
    File "<ipython-input-65-84c451711e90>", line 31, in masked_accuracy_2 *
        pred = label_id_to_token(pred)
    File "<ipython-input-13-0c7c54396a6d>", line 2, in label_id_to_token  *
        return [id2output[str(key)] for key in np.array(result)]

    NotImplementedError: Cannot convert a symbolic tf.Tensor (ArgMax_1:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported.

If I iterate over the result in label_id_to_token function without np.array

def label_id_to_token(result):
  # Uses dict id2output
  return [id2output[str(key)] for key in result]

I get an error:

ValueError: in user code:

    File "/usr/local/lib/python3.8/dist-packages/keras/engine/training.py", line 1290, in train_function  *
        for _ in tf.range(self._steps_per_execution):

    ValueError: 'outputs' must be defined before the loop
    Note: AutoGraph tried to define it automatically, but ran into a OperatorNotAllowedInGraphError: in user code:

        File "<ipython-input-70-7e2d0a74e115>", line 31, in masked_accuracy2  *
            pred = decode(pred)
        File "<ipython-input-62-9a80429dbc49>", line 2, in label_id_to_token  *
            return [id2output[str(key)] for key in result]

        OperatorNotAllowedInGraphError: Iterating over a symbolic `tf.Tensor` is not allowed: AutoGraph did convert this function. This might indicate you are trying to use an unsupported feature.


问:
Oracle Apex Data Load Definitions
I am working with Apex data loading in order to import CSV files. I create 2 different Definitions (Shared Components) because I need to import CSV files with differente columns. I successfully test&debug both and used correctly in the app.
I have an issue due to a file that is not recognized as csv type by one of the data loading page but, just as a test, if I try to upload with the other, the validation pass.</p>

Title: Oracle Apex Data Load Definitions


问:
I am using Azure PAAS service of Postgresql Flexible Server
I have installed the packages postgresql12-odbc (not just postgresql-odbc) and unixODBC and client tool as well

while connection from my applicatio server I got psql: /usr/pgsql-12/lib/libpq.so.5: no version information available (required by psql) psql (12.12).


问:
Order by today date on datatable
Is there anyway to order datatable, which has a date column and using server-side by ajax data, by today date first and the others rows order by date asc?

I know how to order by date column ASC or DESC.. but how can I do today first and then ASC

hope anyone could help me

Title: Order by today date on datatable


问:
Flutter : Deep linking is not working properly
I implemented deep-linking on my flutter app.

I added this code to my androidManifest.xml file

```<code>    <!-- Deep linking -->
    <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="buddybee.eu" />
        <data android:scheme="https" />
    </intent-filter>
</code>```

It's working, when I click on this (e.g. https://abirahsan.com ) type of link, which starts with https/http. But if the link starts with www. like www.abirahsan.com then it's not working.

How can I solve this problem?

Body:
I implemented deep-linking on my flutter app.

I added this code to my androidManifest.xml file

    <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="buddybee.eu" />
        <data android:scheme="https" />
    </intent-filter>

It's working, when I click on this (e.g. https://abirahsan.com ) type of link, which starts with https/http. But if the link starts with www. like www.abirahsan.com then it's not working.

How can I solve this problem?


问:
mongoose prehook fails for updateOne call
My database schema is this on high level:

```<code>{"host_id" : Object ID,
"hostname":<string>,
"userNames":[] //Array of userNames
"usersCount: <Number> }
</code>```

usersCount field should hold the Total Count of users present at that instant.

While adding/deleting userNames as part of updateOne calls , i have added pre-hook to the updateOne calls.

```<code>async function addUsers(user){
...
...

await host.updateOne({ $addToSet: { 'userNames': user.name } });

}
</code>```

Prehook for updateOne calls

```<code>  host.pre('updateOne', updateUsersCount);

  const updateUsersCount = function () {
    this.set([{ usersCount: { $size: "$userNames" }}])

  }
</code>```

The pre-hook query runs in mongo shell but fails from script.I can see the query getting invoked and it doesn't throw any error/exceptions, but nothing gets written to the db. What am i missing here ? or is there a better way to do this ?
I need to have the count field updated  depending on the array increase/decrease

Body:
My database schema is this on high level:

{"host_id" : Object ID,
"hostname":<string>,
"userNames":[] //Array of userNames
"usersCount: <Number> }

usersCount field should hold the Total Count of users present at that instant.

While adding/deleting userNames as part of updateOne calls , i have added pre-hook to the updateOne calls.

async function addUsers(user){
...
...

await host.updateOne({ $addToSet: { 'userNames': user.name } });

}

Prehook for updateOne calls

  host.pre('updateOne', updateUsersCount);

  const updateUsersCount = function () {
    this.set([{ usersCount: { $size: "$userNames" }}])

  }

The pre-hook query runs in mongo shell but fails from script.I can see the query getting invoked and it doesn't throw any error/exceptions, but nothing gets written to the db. What am i missing here ? or is there a better way to do this ?
I need to have the count field updated  depending on the array increase/decrease


问:
html href link disable conversion to ip address
I have a weird one, don't even know how to search for it.

I'm building a custom portal and I have links like these:

Link 1

Link 2```

xyz:// opens an application on my computer that knows what to do with that number.

The problem is that the first link is converted by the browser to xyz://0.3.34.63

I know it's because the number is less than 8 digits and it could be an ip address in hex format, but it's not.

How do I tell the browser to trust me and leave it as it is?

Thanks

Body:
I have a weird one, don't even know how to search for it.

I'm building a custom portal and I have links like these:

Link 1

Link 2

xyz:// opens an application on my computer that knows what to do with that number.

The problem is that the first link is converted by the browser to xyz://0.3.34.63

I know it's because the number is less than 8 digits and it could be an ip address in hex format, but it's not.

How do I tell the browser to trust me and leave it as it is?

Thanks


问:
Electron UI load native C++ addon on Windows error
I've createed simple native add-on using generator-napi-module. The module is successfully built.
Also, I've added folowing line in window.js:

```<code>const testmodule = require('testmodule')
</code>```

When I start app with npm start, I've got following error:

```<code>    ELECTRON_ASAR.js:166 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\build\Release\testmodule-native.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620)
    at tryModuleLoad (internal/modules/cjs/loader.js:559)
    at Function.Module._load (internal/modules/cjs/loader.js:551)
    at Module.require (internal/modules/cjs/loader.js:658)
    at require (internal/modules/cjs/helpers.js:20)
    at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:1)
    at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:6)
</code>```

The module is working properly when I execute command:

```<code>node index
</code>```

or test with:

```<code>npm test
</code>```

What could go wrong here? Could this be related to security?

Also note that I tried to play with ffi-napi to load native library but the same error message appears.

Body:
I've createed simple native add-on using generator-napi-module. The module is successfully built.
Also, I've added folowing line in window.js:

const testmodule = require('testmodule')

When I start app with npm start, I've got following error:

    ELECTRON_ASAR.js:166 Uncaught Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\build\Release\testmodule-native.node
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
    at Module.load (internal/modules/cjs/loader.js:620)
    at tryModuleLoad (internal/modules/cjs/loader.js:559)
    at Function.Module._load (internal/modules/cjs/loader.js:551)
    at Module.require (internal/modules/cjs/loader.js:658)
    at require (internal/modules/cjs/helpers.js:20)
    at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:1)
    at Object.<anonymous> (C:\Electron\simple-samples-master\activity-monitor\node_modules\testmodule\lib\binding.js:6)

The module is working properly when I execute command:

node index

or test with:

npm test

What could go wrong here? Could this be related to security?

Also note that I tried to play with ffi-napi to load native library but the same error message appears.