Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gap detection #244

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/Projection/PdoEventStoreProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,14 @@ public function run(bool $keepRunning = true): void
}

if ($gapDetected && $this->gapDetection) {
$sleep = $this->gapDetection->getSleepForNextRetry();

\usleep($sleep);
\usleep($this->gapDetection->getSleepForNextRetry() * 1000);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about whether we should do the calculation or change the documentation and tell people that sleep time is configured in microseconds 🤔

When multiplying sleep time 1 ms is the shortest sleep interval possible. Maybe that's too long for some use cases?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The good thing is, changing documentation wouldn't change the current behavior. Gap detection is used in production systems, so people have already identified the best sleep time settings for their projections.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with @codeliner here - afaik this is a BC (as unfortunate it may be).

$this->gapDetection->trackRetry();
$this->persist();
} else {
$this->gapDetection && $this->gapDetection->resetRetries();

if (0 === $this->eventCounter) {
\usleep($this->sleep);
\usleep($this->sleep * 1000);
$this->updateLock();
} else {
$this->persist();
Expand Down
6 changes: 2 additions & 4 deletions src/Projection/PdoEventStoreReadModelProjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,14 @@ public function run(bool $keepRunning = true): void
}

if ($gapDetected && $this->gapDetection) {
$sleep = $this->gapDetection->getSleepForNextRetry();

\usleep($sleep);
\usleep($this->gapDetection->getSleepForNextRetry() * 1000);
$this->gapDetection->trackRetry();
$this->persist();
} else {
$this->gapDetection && $this->gapDetection->resetRetries();

if (0 === $this->eventCounter) {
\usleep($this->sleep);
\usleep($this->sleep * 1000);
$this->updateLock();
} else {
$this->persist();
Expand Down