-
Notifications
You must be signed in to change notification settings - Fork 6
add logging for upload queue processing (WP-1014) #629
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
Open
vsolovei-smartling
wants to merge
10
commits into
master
Choose a base branch
from
WP-1014-upload-assets-failing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0d5f57e
make upload queue crash-safe and stop false fatal reports (WP-1014)
vsolovei-smartling ce1c36d
cleanup (WP-1014)
vsolovei-smartling 1a4910a
restore shutdownHandler fix and stop dropping sibling submissions sil…
vsolovei-smartling 30f015d
fix PR #629 review findings in upload queue crash-safety (WP-1014)
vsolovei-smartling 5ba40b0
fix uncaught exception in upload queue and trait constant fatal error…
vsolovei-smartling 1f13c1a
cleanup (WP-1014)
vsolovei-smartling 1fcd44c
fix PR #629 review findings: silent submission drop and migration fai…
vsolovei-smartling 33ed255
fix PR #629 review findings: unresolvable queue rows never claimed, c…
vsolovei-smartling a2af216
check delete() result to stop dequeue() spinning on a failed discard …
vsolovei-smartling 3b05551
check claim() result before handing out a dequeued item (WP-1014)
vsolovei-smartling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| namespace Smartling\DbAl\Migrations; | ||
|
|
||
| use Smartling\Base\SmartlingEntityAbstract; | ||
| use Smartling\DbAl\DB; | ||
| use Smartling\Models\UploadQueueEntity; | ||
|
|
||
| /** | ||
| * Adds claim tracking to the upload queue. | ||
| * | ||
| * Queue rows used to be deleted the moment they were handed to the upload job, so a | ||
| * fatal error, timeout or out of memory during the upload that followed destroyed the | ||
| * queued work without a trace. Rows are now claimed instead, and only removed once the | ||
| * upload has been accounted for. | ||
| */ | ||
| class Migration260825 implements SmartlingDbMigrationInterface | ||
| { | ||
| public function getVersion(): int | ||
| { | ||
| return 260825; | ||
| } | ||
|
|
||
| public function getQueries($tablePrefix = 'wp_'): array | ||
| { | ||
| $db = new DB(); | ||
| $tableName = $db->completeTableName(UploadQueueEntity::getTableName()); | ||
|
|
||
| // Migration240315 (re)creates this table with `CREATE TABLE IF NOT EXISTS` from the | ||
| // current, evolving UploadQueueEntity::getFieldDefinitions(). A site upgrading from a | ||
| // schema version older than 240315 runs that migration first, and it already creates | ||
| // the table with the columns below, so blindly adding them here would fail with a | ||
| // duplicate column error. Only add what isn't already there. | ||
| $existingColumns = $db->getColumnArray("SHOW COLUMNS FROM `$tableName`"); | ||
|
|
||
| $columns = [ | ||
| UploadQueueEntity::FIELD_CLAIMED => SmartlingEntityAbstract::DB_TYPE_DATETIME_NULL, | ||
| UploadQueueEntity::FIELD_ATTEMPTS => SmartlingEntityAbstract::DB_TYPE_U_BIGINT . ' ' . SmartlingEntityAbstract::DB_TYPE_DEFAULT_ZERO, | ||
| ]; | ||
|
|
||
| $queries = []; | ||
| foreach ($columns as $column => $definition) { | ||
| if (!in_array($column, $existingColumns, true)) { | ||
| $queries[] = sprintf('ALTER TABLE `%s` ADD COLUMN `%s` %s', $tableName, $column, $definition); | ||
| } | ||
| } | ||
|
|
||
| return $queries; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 suggestion —
getStaleClaimThreshold()builds its ownnew \DateTimeZone(DateTimeHelper::TIMEZONE_UTC)explicitly, whileclaim()(below) stores the claim time viaDateTimeHelper::nowAsString(), which usesDateTimeHelper::getDefaultTimezone()— UTC only because nothing currently overrides it. These two time sources aren't structurally guaranteed to agree. Consider computing both via the same helper so a future change to the default timezone can't silently desync staleness detection from claim timestamps.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Synchronized