Skip to content

Update last modified date directly in touch #2014

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

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

greglittlefield-wf
Copy link
Contributor

This mitigates race conditions in which concurrent Pub processes "touch"
pubspec.lock at the same time and leave it with a trailing NUL character.


Long-winded background info

We've been seeing intermittent failures in our automated builds for some time now, which looked like this:

Error on line 1177, column 1 of pubspec.lock: Unexpected character.

^

However, we had a hard time tracking them down. Eventually, we determined that the unexpected character in that message was actually a NUL character.

"What was modifying pubspec.lock and adding a NUL character?" We weren't in our scripts, and there shouldn't be any reason for Pub to modify it since in all cases we've seen this issue, the pubspec.lock is checked in and didn't change after pub get.

However, looking at Pub's source, it looks like its touch utility operates by writing a NUL character to the end of the file and then writing to it again with the original contents.

We were running multiple Pub commands in parallel, which would explain this issue: two Pub processes could be performing touch at the same time,
resulting in a NUL character being preserved in the output.

pub run also always touches pubspec.lock when there are path dependencies, which we had in all the repos we encountered this issue in, which explains why we were seeing it so often.

To reproduce locally: with the following files...

  • pubspec.yaml
    name: foo
    dependencies:
      path_dep:
        path: ./path_dep
  • foo.dart
    main() {}
  • path_dep/pubspec.yaml
    name: path_dep

... run the following command in several of terminals at once;
eventually you'll get "Unexpected character" errors.

while true; do pub run ./foo.dart; done

This mitigates race conditions in which concurrent Pub processes "touch"
pubspec.lock around the same time and leave it with a trailing NUL character.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@greglittlefield-wf
Copy link
Contributor Author

I signed it! (My company, Workiva, signed it!)

I know in the past, our CLA hasn't been picked up by googlebot. I see that the CLA instructions have changed, so perhaps I need to get in touch with our Point of Contact. I don't know who that is, though ☹️.

@natebosch
Copy link
Member

cc @mit-mit

@mit-mit
Copy link
Member

mit-mit commented Dec 11, 2018

What do you see if you go to https://cla.developers.google.com/clas ?

Did the git commit use an @workiva.com email address?

@greglittlefield-wf
Copy link
Contributor Author

I see this:

screen shot 2018-12-11 at 3 07 03 pm

Yes, the commit uses [email protected].

@mit-mit
Copy link
Member

mit-mit commented Dec 11, 2018

Got it, let me do some debugging on my end

@greglittlefield-wf
Copy link
Contributor Author

Thanks!!

@mit-mit
Copy link
Member

mit-mit commented Dec 11, 2018

Can you verify that you are a member of [email protected]? That's the group that the class is tied to.

@greglittlefield-wf
Copy link
Contributor Author

Hm, not that I can tell. Let me ask around...

@greglittlefield-wf
Copy link
Contributor Author

Hey @mit-mit, I just got added to that group!

@googlebot
Copy link

CLAs look good, thanks!

@mit-mit
Copy link
Member

mit-mit commented Feb 20, 2019

@jonasfj & @natebosch can you take a look at this PR?

@mit-mit mit-mit requested review from jonasfj and natebosch February 20, 2019 13:37
@jonasfj jonasfj merged commit 135e10a into dart-lang:master Feb 27, 2019
@robbecker-wf
Copy link

🎉 Any idea which Dart SDK version this will be released in?

@kevmoo
Copy link
Member

kevmoo commented Feb 27, 2019

Need to merge it into the SDK first. Then it'll be "the next one".

Updated dart-lang/sdk#36026 to make the request for @sigurdm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants