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

Cherry-pick #18738 to 7.x: Improve thread safety of fingerprint processor #18926

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

urso
Copy link

@urso urso commented Jun 3, 2020

Cherry-pick of PR #18738 to 7.x branch. Original message:

  • Bug

What does this PR do?

Remove the reuse of the hash function between runs in the hash processor.

Running the benchmarks seems to suggest that we don't create any extra
allocations with this change (tested with go1.13):

$ go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/elastic/beats/v7/libbeat/processors/fingerprint
BenchmarkHashMethods/sha384-4         	1000000000	         0.123 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashMethods/sha512-4         	1000000000	         0.125 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashMethods/xxhash-4         	1000000000	         0.0539 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashMethods/md5-4            	1000000000	         0.0925 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashMethods/sha1-4           	1000000000	         0.112 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashMethods/sha256-4         	1000000000	         0.134 ns/op	       0 B/op	       0 allocs/op

Why is it important?

The fingerprint processor used to reuse state between calls, but not
being threadsafe means that the processor might get into an invalid
state if it is used by multiple go-routines by accident, creating
invalid, non-reproducible hash values. This change does not reuse the
hash state between runs.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
    - [ ] I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@urso urso added [zube]: In Review backport Team:Services (Deprecated) Label for the former Integrations-Services team labels Jun 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 3, 2020
Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

Backport LGTM.

@elasticmachine
Copy link
Collaborator

💔 Tests Failed

Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #18926 opened]

  • Start Time: 2020-06-03T11:17:22.349+0000

  • Duration: 71 min 43 sec

Test stats 🧪

Test Results
Failed 6
Passed 6526
Skipped 1061
Total 7593

Test errors

Expand to view the tests failures

  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestData – channels

    • Age: 1
    • Duration: 25.15
    • Error Details: Failed
  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestFetch – channels

    • Age: 1
    • Duration: 11.51
    • Error Details: Failed
  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestData – stats

    • Age: 1
    • Duration: 44.22
    • Error Details: Failed
  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestFetch – stats

    • Age: 1
    • Duration: 34.22
    • Error Details: Failed
  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestData – subscriptions

    • Age: 1
    • Duration: 55.34
    • Error Details: Failed
  • Name: Build and Test / Metricbeat x-pack / Metricbeat x-pack / TestFetch – subscriptions

    • Age: 1
    • Duration: 11.5
    • Error Details: Failed

Steps errors

Expand to view the steps failures

  • Name: Make -C libbeat testsuite

    • Description: make -C libbeat testsuite

    • Duration: 32 min 41 sec

    • Start Time: 2020-06-03T11:40:07.229+0000

    • log

  • Name: Mage build test

    • Description: mage build test

    • Duration: 33 min 17 sec

    • Start Time: 2020-06-03T11:43:46.255+0000

    • log

Log output

Expand to view the last 100 lines of log output

[2020-06-03T12:27:30.833Z] Stashed 39 file(s)
[2020-06-03T12:27:30.852Z] Archiving artifacts
[2020-06-03T12:27:32.201Z] + curl -sSLo codecov https://codecov.io/bash
[2020-06-03T12:27:32.499Z] + FILE=auditbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f auditbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=filebeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f filebeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=heartbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f heartbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=libbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f libbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=metricbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f metricbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=packetbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f packetbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=winlogbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f winlogbeat/build/coverage/full.cov ]
[2020-06-03T12:27:32.499Z] + FILE=journalbeat/build/coverage/full.cov
[2020-06-03T12:27:32.499Z] + [ -f journalbeat/build/coverage/full.cov ]
[2020-06-03T12:27:35.760Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats
[2020-06-03T12:27:36.093Z] + find . -type f -name TEST*.xml -path */build/* -delete
[2020-06-03T12:27:36.117Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Lint
[2020-06-03T12:27:36.269Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Winlogbeat-oss
[2020-06-03T12:27:36.419Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Elastic-Agent-x-pack
[2020-06-03T12:27:36.567Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Auditbeat-crosscompile
[2020-06-03T12:27:36.717Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Dockerlogbeat
[2020-06-03T12:27:36.865Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Journalbeat-oss
[2020-06-03T12:27:37.012Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Generators-Metricbeat-Linux
[2020-06-03T12:27:37.158Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Functionbeat-x-pack
[2020-06-03T12:27:37.306Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Elastic-Agent-x-pack-Windows
[2020-06-03T12:27:37.453Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-OSS-Unit-tests
[2020-06-03T12:27:37.599Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-crosscompile
[2020-06-03T12:27:37.745Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Heartbeat-oss
[2020-06-03T12:27:37.890Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Auditbeat-x-pack
[2020-06-03T12:27:38.037Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Auditbeat-oss-Windows
[2020-06-03T12:27:38.184Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Auditbeat-x-pack-Windows
[2020-06-03T12:27:38.328Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Winlogbeat-Windows-x-pack
[2020-06-03T12:27:38.479Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Libbeat-x-pack
[2020-06-03T12:27:38.627Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Filebeat-Windows
[2020-06-03T12:27:38.772Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Auditbeat-oss-Linux
[2020-06-03T12:27:38.921Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Filebeat-x-pack-Windows
[2020-06-03T12:27:39.070Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Packetbeat-oss
[2020-06-03T12:27:39.220Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-Windows
[2020-06-03T12:27:39.366Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Winlogbeat-Windows
[2020-06-03T12:27:39.512Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack-Windows
[2020-06-03T12:27:39.660Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Generators-Beat-Linux
[2020-06-03T12:27:39.814Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Filebeat-x-pack
[2020-06-03T12:27:39.968Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Functionbeat-Windows
[2020-06-03T12:27:40.117Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Heartbeat-Windows
[2020-06-03T12:27:40.269Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Libbeat-oss
[2020-06-03T12:27:40.422Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Filebeat-oss
[2020-06-03T12:27:40.573Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-Python-integration-tests
[2020-06-03T12:27:40.719Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack
[2020-06-03T12:27:40.867Z] Running in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests
[2020-06-03T12:27:41.304Z] + cat
[2020-06-03T12:27:41.304Z] + /usr/local/bin/runbld ./runbld-script
[2020-06-03T12:27:41.304Z] Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
[2020-06-03T12:27:47.909Z] runbld>>> runbld started
[2020-06-03T12:27:47.909Z] runbld>>> 1.6.11/a66728ff8f4356963772e6e6d2069392fa06acbe
[2020-06-03T12:27:49.825Z] runbld>>> The following profiles matched the job 'Beats/beats-beats-mbp/PR-18926' in order of occurrence in the config (last value wins).
[2020-06-03T12:27:50.769Z] runbld>>> Debug logging enabled.
[2020-06-03T12:27:50.769Z] runbld>>> Storing result
[2020-06-03T12:27:51.032Z] runbld>>> Store result: created {:total 2, :successful 2, :failed 0} 1
[2020-06-03T12:27:51.032Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200603122750-51C32E0D
[2020-06-03T12:27:51.032Z] runbld>>> Adding system facts.
[2020-06-03T12:27:51.983Z] runbld>>> Adding vcs info for the latest commit:  60e3df6319d5c0275183192f029dc4d096efcc50
[2020-06-03T12:27:52.246Z] runbld>>> >>>>>>>>>>>> SCRIPT EXECUTION BEGIN >>>>>>>>>>>>
[2020-06-03T12:27:52.246Z] runbld>>> Adding /usr/lib/jvm/java-8-openjdk-amd64/bin to the path.
[2020-06-03T12:27:52.246Z] Processing JUnit reports with runbld...
[2020-06-03T12:27:52.246Z] + echo 'Processing JUnit reports with runbld...'
[2020-06-03T12:27:52.822Z] runbld>>> <<<<<<<<<<<< SCRIPT EXECUTION END <<<<<<<<<<<<
[2020-06-03T12:27:52.822Z] runbld>>> DURATION: 27ms
[2020-06-03T12:27:52.822Z] runbld>>> STDOUT: 40 bytes
[2020-06-03T12:27:52.822Z] runbld>>> STDERR: 49 bytes
[2020-06-03T12:27:52.822Z] runbld>>> WRAPPED PROCESS: SUCCESS (0)
[2020-06-03T12:27:52.823Z] runbld>>> Searching for build metadata in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats
[2020-06-03T12:27:54.214Z] runbld>>> Storing build metadata: 
[2020-06-03T12:27:54.214Z] runbld>>> Adding test report.
[2020-06-03T12:27:54.214Z] runbld>>> Searching for junit test output files with the pattern: TEST-.*\.xml$ in: /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats
[2020-06-03T12:27:55.160Z] runbld>>> Found 97 test output files
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-graphite.xml
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-OSS-Integration-tests/metricbeat/build/TEST-go-integration-windows.xml
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-openmetrics.xml
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-cloudfoundry.xml
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-iis.xml
[2020-06-03T12:27:55.423Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-istio.xml
[2020-06-03T12:27:55.686Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-activemq.xml
[2020-06-03T12:27:55.686Z] runbld>>> No testsuite node found in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926/src/github.com/elastic/beats/Metricbeat-x-pack/x-pack/metricbeat/build/TEST-go-integration-tomcat.xml
[2020-06-03T12:27:57.075Z] runbld>>> Test output logs contained: Errors: 0 Failures: 6 Tests: 7443 Skipped: 861
[2020-06-03T12:27:57.075Z] runbld>>> Storing result
[2020-06-03T12:27:57.075Z] runbld>>> FAILURES: 6
[2020-06-03T12:27:58.458Z] runbld>>> Store result: updated {:total 2, :successful 2, :failed 0} 2
[2020-06-03T12:27:58.458Z] runbld>>> BUILD: https://c150076387b5421f9154dfbf536e5c60.us-west1.gcp.cloud.es.io:9243/build-1587637540455/t/20200603122750-51C32E0D
[2020-06-03T12:28:04.013Z] Running on Jenkins in /var/lib/jenkins/workspace/Beats_beats-beats-mbp_PR-18926
[2020-06-03T12:28:04.231Z] [INFO] getVaultSecret: Getting secrets
[2020-06-03T12:28:04.288Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2020-06-03T12:28:05.220Z] + chmod 755 generate-build-data.sh
[2020-06-03T12:28:05.220Z] + ./generate-build-data.sh https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18926/ https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18926/runs/1 FAILURE 4242601
[2020-06-03T12:28:05.220Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18926/runs/1/steps/?limit=10000 -o steps-info.json
[2020-06-03T12:28:06.563Z] INFO: curl https://beats-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/Beats/beats-beats-mbp/PR-18926/runs/1/tests/?status=FAILED -o tests-errors.json

@urso urso merged commit 218e16c into elastic:7.x Jun 4, 2020
@urso urso deleted the backport_18738_7.x branch June 4, 2020 13:03
@zube zube bot removed the [zube]: Done label Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants