[MM-22314] Remove read limit at app/import which cause bulk import to fail (#13863)
* app/import: increase buffer size to avoid failing in large inputs * remove commented out lock * app/import: make maxTokenSize constant Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e922541cc5
Коммит
d5df6a3fc4
@@ -16,6 +16,8 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
)
|
||||
|
||||
const maxScanTokenSize = 16 * 1024 * 1024 // Need to set a higher limit than default because some customers cross the limit. See MM-22314
|
||||
|
||||
func stopOnError(err LineImportWorkerError) bool {
|
||||
if err.Error.Id == "api.file.upload_file.large_image.app_error" {
|
||||
mlog.Warn("Large image import error", mlog.Err(err.Error))
|
||||
@@ -35,6 +37,9 @@ func (a *App) bulkImportWorker(dryRun bool, wg *sync.WaitGroup, lines <-chan Lin
|
||||
|
||||
func (a *App) BulkImport(fileReader io.Reader, dryRun bool, workers int) (*model.AppError, int) {
|
||||
scanner := bufio.NewScanner(fileReader)
|
||||
buf := make([]byte, 0, 64*1024)
|
||||
scanner.Buffer(buf, maxScanTokenSize)
|
||||
|
||||
lineNumber := 0
|
||||
|
||||
a.Srv().Store.LockToMaster()
|
||||
@@ -104,7 +109,9 @@ func (a *App) BulkImport(fileReader io.Reader, dryRun bool, workers int) (*model
|
||||
}
|
||||
|
||||
// No more lines. Clear out the worker queue before continuing.
|
||||
close(linesChan)
|
||||
if linesChan != nil {
|
||||
close(linesChan)
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
// Check no errors occurred while waiting for the queue to empty.
|
||||
@@ -119,10 +126,6 @@ func (a *App) BulkImport(fileReader io.Reader, dryRun bool, workers int) (*model
|
||||
return model.NewAppError("BulkImport", "app.import.bulk_import.file_scan.error", nil, err.Error(), http.StatusInternalServerError), 0
|
||||
}
|
||||
|
||||
if err := a.finalizeImport(dryRun); err != nil {
|
||||
return err, 0
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
@@ -180,10 +183,3 @@ func (a *App) importLine(line LineImportData, dryRun bool) *model.AppError {
|
||||
return model.NewAppError("BulkImport", "app.import.import_line.unknown_line_type.error", map[string]interface{}{"Type": line.Type}, "", http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) finalizeImport(dryRun bool) *model.AppError {
|
||||
if dryRun {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user