2013-03-18 3 views
2

PHP 작업 기반 클래스에서 Pheanstalk을 감싸려고합니다. 예비 기능과 예비 기능을 지연 기능으로 테스트 중이며 작업 또는 TTR 시간 초과를 해제하지 않고 기본 클래스의 두 번째 인스턴스에서 작업을 예약 할 수 있음을 발견했습니다. 이것은 작업 대기열이 방지해야하는 작업이라고 생각했기 때문에 예상치 못한 것입니다. 다음은 첫 번째 put과 첫 번째 예약에 대한 beanstalkd 명령과 타임 스탬프입니다. 또한 마지막에 통계 작업 요청을 수행합니다.Beanstalkd (pheanstalk를 통해) 중복, 동시 예약이 가능합니까?

01:40:15: Sending command: use QueuedCoreEvent 
01:40:15: Got response: USING QueuedCoreEvent 

01:40:15: Sending command: put 1024 0 300 233 
a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;} 
01:40:15: Got response: INSERTED 10 

01:40:15: Sending command: watch QueuedCoreEvent 
01:40:15: Got response: WATCHING 2 

01:40:15: Sending command: ignore default 
01:40:15: Got response: WATCHING 1 

01:40:15: Sending command: reserve-with-timeout 0 
01:40:15: Got response: RESERVED 10 233 
01:40:15: Data: a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;} 

01:40:15: Sending command: stats-job 10 
01:40:15: Got response: OK 162 
01:40:15: Data: --- 
id: 10 
tube: QueuedCoreEvent 
state: reserved 
pri: 1024 
age: 0 
delay: 0 
ttr: 300 
time-left: 299 
file: 0 
reserves: 1 
timeouts: 0 
releases: 0 
buries: 0 
kicks: 0 

지금까지는 그렇게 좋았습니다. 이제베이스 클래스의 두 번째 인스턴스에서 또 다른 예약 작업을 수행 한 다음 다른 통계 작업 요청을 수행합니다. 타임 스탬프는 내가 설정 한 300 초 TTR 근처의 아무 곳에서도 찾을 수 있습니다. 또한이 두 번째 통계 작업 출력에는 0 작업 제한과 0 릴리스가있는이 작업의 예약이 2 개 있음을 알 수 있습니다.

01:40:15: Sending command: watch QueuedCoreEvent 
01:40:15: Got response: WATCHING 2 

01:40:15: Sending command: ignore default 
01:40:15: Got response: WATCHING 1 

01:40:15: Sending command: reserve-with-timeout 0 
01:40:15: Got response: RESERVED 10 233 
01:40:15: Data: a:4:{s:9:"eventName";s:21:"ReQueueJob_eawu7xr9bi";s:6:"params";a:2:{s:12:"InstanceName";s:21:"ReQueueJob_eawu7xr9bi";s:17:"aValueToIncrement";i:123456;}s:9:"behaviors";a:1:{i:0;s:22:"BehMCoreEventTestDummy";}s:12:"failureCount";i:0;} 

01:40:15: Sending command: stats-job 10 
01:40:15: Got response: OK 162 
01:40:15: Data: --- 
id: 10 
tube: QueuedCoreEvent 
state: reserved 
pri: 1024 
age: 0 
delay: 0 
ttr: 300 
time-left: 299 
file: 0 
reserves: 2 
timeouts: 0 
releases: 0 
buries: 0 
kicks: 0 

누구나 내가 잘못하고있는 것에 대해 아이디어가 있습니까? 작업 대기열에 한 번에 한 명의 작업자 만 액세스 할 수 있기를 원한다면 뭔가해야합니까? 내가 beanstalkd로 세션을 종료한다고 생각한 대기열에서 작업을 얻 자마자 pheanstalk 인스턴스에서 "unset"을 수행하고 있습니다. 이로 인해 Beanstalkd가 작업자가 사망했으며 시간 초과없이 작업을 자동으로 해제 할 수 있다고 판단 할 수 있습니까? 얼마나 많은 beanstalkd가 작업자 상태를 결정하기 위해 세션 상태에 의존하는지 잘 모르겠습니다. 나는 비공개로 세션을 열고 닫을 수 있다고 가정하고 있었고, 그 작업 ID만으로도 Beanstalkd가 작업 작업을 묶을 수있는 유일한 방법 이었지만, 그것은 내 부분에서 어리석은 것일 수 있습니다 ... 이것은 작업 대기열에 대한 첫 번째 진출입니다. .

감사합니다.

+0

그러나 나는 그것을 발견 : 여기

은 예입니다 아파치가 완전히 죽을 때까지 무한히 돌아가는 cron 작업. 그러나 내가 말한 것은 작업이 완료되면 삭제할 가능성이 높다는 것입니다. 그렇지 않으면 대기열에 남아 있고 대기열 작업을 실행하는 작업자가있는 한 최선의 시나리오 인 300 번마다 다시 실행됩니다. 지금까지 통신이 설정되지 않은 pheanstalk 인스턴스를 btwn하고 주석을 달 수없는 작업을 릴리스했습니다. –

답변

2

내 생각 엔 첫 번째 클라이언트 인스턴스가 두 번째 서버가 작업을 예약하기 전에 beanstalkd 서버에 대한 TCP 소켓을 닫았습니다.

TCP 연결을 닫으면 작업이 암시 적으로 대기열로 해제됩니다. 이러한 암시 적 릴리스 (닫기 연결, quit 명령 등)는 releases 카운터를 증가시키지 않는 것 같습니다. 내 원인 - 즉, 결코 반환하지 않습니다 - 내`pheanstalk-> 준비 제도 이사회()`호출이 실속 된 이유를 확인하는 동안 문제가 무엇인지 나는 아무 생각

# Create a job, reserve it, close the connection: 
[email protected] ~ > telnet 0 11300 
Trying 0.0.0.0... 
Connected to 0. 
Escape character is '^]'. 
put 0 0 600 5 
hello 
INSERTED 1 
reserve 
RESERVED 1 5 
hello 
^] 
telnet> close 
Connection closed. 

# Reserve the job, stats-job shows two reserves, zero releases. 
# Use 'quit' command to close connection. 
[email protected] ~ > telnet 0 11300 
Trying 0.0.0.0... 
Connected to 0. 
Escape character is '^]'. 
reserve 
RESERVED 1 5 
hello 
stats-job 1 
OK 151 
--- 
id: 1 
tube: default 
state: reserved 
pri: 0 
age: 33 
delay: 0 
ttr: 600 
time-left: 593 
file: 0 
reserves: 2 
timeouts: 0 
releases: 0 
buries: 0 
kicks: 0 

quit 
Connection closed by foreign host. 

# Reserve the job, stats-job still shows zero releases. 
# Explicitly release the job, stats-job shows one release. 
[email protected] ~ > telnet 0 11300 
Trying 0.0.0.0... 
Connected to 0. 
Escape character is '^]'. 
reserve 
RESERVED 1 5 
hello 
stats-job 1 
OK 151 
--- 
id: 1 
tube: default 
state: reserved 
pri: 0 
age: 46 
delay: 0 
ttr: 600 
time-left: 597 
file: 0 
reserves: 3 
timeouts: 0 
releases: 0 
buries: 0 
kicks: 0 

release 1 0 0 
RELEASED 
stats-job 1 
OK 146 
--- 
id: 1 
tube: default 
state: ready 
pri: 0 
age: 68 
delay: 0 
ttr: 600 
time-left: 0 
file: 0 
reserves: 3 
timeouts: 0 
releases: 1 
buries: 0 
kicks: 0 

quit 
Connection closed by foreign host.