JDBC和HTTP请求在多个线程上

huangapple go评论60阅读模式
英文:

JDBC and HTTP request on multiple threads

问题

我有以下结构:
>>线程

>> JDBC 请求,从表中获取前100个结果,并用“,”分隔符连接它们(例如“1,2,3,4,5”)

>> DELETE 调用,使用由 JDBC 请求创建的包含这些 ID 的变量,用“,”分隔符。

事情在1个线程上运行正常,但一旦增加线程,问题就会发生。例如,使用2个线程时出现的问题是,JDBC 请求会执行2次并获取相同的 ID,然后 DELETE 调用会执行2次 - 第一次成功,因为调用是有效的,但在下一次调用时(用户2/2),它会失败,因为这些 ID 已经被删除。

我正在寻找解决这个问题的任何想法。

尝试过“仅一次控制器”,但线程数量会下降,例如到100,然后会下降,对于主请求,我看到只有1个。

英文:

I have the following structure:
>>Thread

>> JDBC request which takes top 100 resuts from a table and concatenate them with ',' separator (e.g. "1,2,3,4,5")

>> DELETE call which is using the variable created by the JDBC request which include those IDs with "," separator.

The things work on 1 thread, but the problem occur once I increase the threads. The problem, that arise with 2 threads, for example, is that the JDBC request is getting executed 2 times and gets the same IDs, then the DELETE call is executed 2 times - first time is successfull, because the call is valid, but on the next call (user 2/2) it fails, because those ids are already deleted.

I'm searching for any ideas how that can be solved.

Tried with "Once Only Controller", but the threads are going down up to e.g. 100, and then going down and for the main request I see there is only 1.

答案1

得分: 1

"Instead of "top 100" you should go for LIMIT and OFFSET"

作为“LIMIT”,您可以使用100,作为“OFFSET”,您可以使用当前线程号乘以100

可以使用如下方式实现,即使用__threadNum()__jexl3()函数组合

${__jexl3(${__threadNum} * 100,)}

JDBC和HTTP请求在多个线程上

有关JMeter函数概念的更多信息:Apache JMeter Functions - An Introduction

英文:

Instead of "top 100" you should go for LIMIT and OFFSET

As the LIMIT you can use 100 and as the OFFSET you can use current thread number multiplied by 100

It can be achieved using i.e. __threadNum() and __jexl3() functions combination

${__jexl3(${__threadNum} * 100,)}

JDBC和HTTP请求在多个线程上

More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

huangapple
  • 本文由 发表于 2023年6月19日 21:27:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76507100.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定