Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15413563
D17795.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D17795.id.diff
View Options
diff --git a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
--- a/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
+++ b/src/infrastructure/storage/management/workflow/PhabricatorStorageManagementDumpWorkflow.php
@@ -138,6 +138,13 @@
$command = csprintf('mysqldump %Ls', $argv);
}
+ // Decrease the CPU priority of this process so it doesn't contend with
+ // other more important things.
+ if (function_exists('proc_nice')) {
+ proc_nice(19);
+ }
+
+
// If we aren't writing to a file, just passthru the command.
if ($output_file === null) {
return phutil_passthru('%C', $command);
@@ -148,7 +155,7 @@
// a full disk). See T6996 for discussion.
if ($is_compress) {
- $file = gzopen($output_file, 'wb');
+ $file = gzopen($output_file, 'wb1');
} else {
$file = fopen($output_file, 'wb');
}
@@ -162,23 +169,35 @@
$future = new ExecFuture('%C', $command);
- $lines = new LinesOfALargeExecFuture($future);
-
try {
- foreach ($lines as $line) {
- $line = $line."\n";
- if ($is_compress) {
- $ok = gzwrite($file, $line);
- } else {
- $ok = fwrite($file, $line);
+ $iterator = id(new FutureIterator(array($future)))
+ ->setUpdateInterval(0.100);
+ foreach ($iterator as $ready) {
+ list($stdout, $stderr) = $future->read();
+ $future->discardBuffers();
+
+ if (strlen($stderr)) {
+ fwrite(STDERR, $stderr);
}
- if ($ok !== strlen($line)) {
- throw new Exception(
- pht(
- 'Failed to write %d byte(s) to file "%s".',
- new PhutilNumber(strlen($line)),
- $output_file));
+ if (strlen($stdout)) {
+ if ($is_compress) {
+ $ok = gzwrite($file, $stdout);
+ } else {
+ $ok = fwrite($file, $stdout);
+ }
+
+ if ($ok !== strlen($stdout)) {
+ throw new Exception(
+ pht(
+ 'Failed to write %d byte(s) to file "%s".',
+ new PhutilNumber(strlen($stdout)),
+ $output_file));
+ }
+ }
+
+ if ($ready !== null) {
+ $ready->resolvex();
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 7:41 PM (3 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7714389
Default Alt Text
D17795.id.diff (2 KB)
Attached To
Mode
D17795: Reduce the impact of `bin/storage dump`
Attached
Detach File
Event Timeline
Log In to Comment